Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
- name: Vars iteration
hosts: all
vars:
users:
user1:
name: user1
key: ssh-key
user2:
name: user2
key: ssh-key2
user:
- user1
tasks:
- name: Iterate user
debug:
msg: "{{ item }}"
with_items:
- user
- name: Iterate users
debug:
msg: "{{ item.value.name }}"
with_dict: "{{ users }}"
- name: Iterate user over users
debug:
msg: "{{ item.value.name }} - {{ item.value.key }}"
with_dict: "{{ users }}"
when: item.key in user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment