mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-01 06:41:26 -07:00
Add example of using loop: with when: statements (#42776)
This commit is contained in:
parent
a9b1af8bdd
commit
d2409fb165
1 changed files with 6 additions and 0 deletions
|
@ -38,6 +38,12 @@ tasks:
|
||||||
debug:
|
debug:
|
||||||
msg: "{{item.key}}: {{item.value}}"
|
msg: "{{item.key}}: {{item.value}}"
|
||||||
with_dict: {a: 1, b: 2, c: 3}
|
with_dict: {a: 1, b: 2, c: 3}
|
||||||
|
# Items from loop can be used in when: statements
|
||||||
|
- name: set_fact when alice in key
|
||||||
|
set_fact:
|
||||||
|
alice_exists: true
|
||||||
|
loop: "{{ lookup('dict', users) }}"
|
||||||
|
when: "'alice' in item.key"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue