Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ansible@control plugins]$ cat mappit.yaml
- ---
- - name: map test
- hosts: localhost
- become: no
- vars_files:
- - addresses.json
- gather_facts: no
- tasks:
- - debug:
- msg: "{{ names | map(attribute='first')}} lives in {{ names | map(attribute='address') | map(attribute='city')}}"
- [ansible@control plugins]$ cat addresses.json
- {"names": [ {
- "first": "anna",
- "address": {
- "city": "Breda",
- "country": "NL"
- }
- },
- {
- "first": "denise",
- "address": {
- "city": "San Francisco",
- "country": "USA"
- }
- },
- {
- "first": "sharon",
- "address": {
- "city": "Mombasa",
- "country": "kenya"
- } ]
- }
- [ansible@control plugins]$ cat addresses.yaml
- names:
- - first: anna
- address:
- city: Breda
- country: NL
- - first: denise
- address:
- city: San Francisco
- country: USA
- - first: sharon
- address:
- city: Mombasa
- country: kenya
Advertisement
Add Comment
Please, Sign In to add comment