Pfoef, describing my issue at hand is quite difficult. Please bear with me.
I have this dict:
my_dict:
FIRST:
some_key: first_value
SECOND:
some_key: second_value
My Ansible task is:
- shell: "echo {{ item.value['some_key'] }}"
register: exec_output
loop: "{{ my_dict | dict2items }}"
# This is something where I do not know what to do
- set_fact:
desired_output: ???
when: <some_key_contains_a_value>
When Ansible executes, it will execute the shell command twice, because there are 2 items in the dict.
Q: How can I configure Ansible so that: Ansible will set a fact and add the key (FIRST or SECOND) if the value of some_key is e.g. 'second_value'. In this example case, the fact will contain "SECOND".