Skip to content

Commit

Permalink
Proposed change to documentation to elaborate on new notation style f…
Browse files Browse the repository at this point in the history
…or with_items / with_subelements
  • Loading branch information
Gerben Geijteman committed Mar 21, 2016
1 parent 9053d04 commit c7e1a65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docsite/rst/playbooks_loops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ It might happen like so::

- authorized_key: "user={{ item.0.name }} key='{{ lookup('file', item.1) }}'"
with_subelements:
- users
- "{{ users }}"
- authorized

Given the mysql hosts and privs subkey lists, you can also iterate over a list in a nested subkey::

- name: Setup MySQL users
mysql_user: name={{ item.0.name }} password={{ item.0.mysql.password }} host={{ item.1 }} priv={{ item.0.mysql.privs | join('/') }}
with_subelements:
- users
- "{{ users }}"
- mysql.hosts

Subelements walks a list of hashes (aka dictionaries) and then traverses a list with a given (nested sub-)key inside of those
Expand Down
2 changes: 1 addition & 1 deletion samples/with_subelements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
tasks:
- debug: msg="user={{ item.0.name }} key='{{ item.1 }}'"
with_subelements:
- users
- "{{ users }}"
- authorized

0 comments on commit c7e1a65

Please sign in to comment.