Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...