Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

is there any way to strip ansible output caused by with_items

I'm new to ansible.

I have a problem when using ansible 'with_items'.

For example, the following code:

- assert:
    that:
      - ...
  with_items: "{{data_array_with_big_elements}}"

The running effect is

TASK [assert] ***************
ok: [10.250.15.160] => (item={......big.....body......here....}) => else_output.

What I want is to strip the item body to a short one.

Is there any idea to make it?

question from:https://stackoverflow.com/questions/65861522/is-there-any-way-to-strip-ansible-output-caused-by-with-items

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can control the info displayed by loops using the loop_control attribute for your task.

- name: A looped task with controlled label
  command: /bin/true
  loop: "{{ some_list }}"
  loop_control:
    label: "Whatever you like, references to {{ item.some_attribute }} possible"

Check the above documentation link for more examples.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...