diff --git a/lib/ansible/plugins/lookup/dict.py b/lib/ansible/plugins/lookup/dict.py index 36e572e224..07ac0adf8a 100644 --- a/lib/ansible/plugins/lookup/dict.py +++ b/lib/ansible/plugins/lookup/dict.py @@ -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 = """