Skip to content

Instantly share code, notes, and snippets.

@11mariom
Created June 30, 2017 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 11mariom/a098ff6194b10ae2aec811e6551646a2 to your computer and use it in GitHub Desktop.
Save 11mariom/a098ff6194b10ae2aec811e6551646a2 to your computer and use it in GitHub Desktop.
- 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