mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 22:31:25 -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:
|
||||
msg: "{{item.key}}: {{item.value}}"
|
||||
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 = """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue