sandervanvugt

Untitled

Dec 24th, 2021
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. [ansible@control plugins]$ cat mappit.yaml
  2. ---
  3. - name: map test
  4. hosts: localhost
  5. become: no
  6. vars_files:
  7. - addresses.json
  8. gather_facts: no
  9. tasks:
  10. - debug:
  11. msg: "{{ names | map(attribute='first')}} lives in {{ names | map(attribute='address') | map(attribute='city')}}"
  12. [ansible@control plugins]$ cat addresses.json
  13. {"names": [ {
  14. "first": "anna",
  15. "address": {
  16. "city": "Breda",
  17. "country": "NL"
  18. }
  19. },
  20. {
  21. "first": "denise",
  22. "address": {
  23. "city": "San Francisco",
  24. "country": "USA"
  25. }
  26. },
  27. {
  28. "first": "sharon",
  29. "address": {
  30. "city": "Mombasa",
  31. "country": "kenya"
  32. } ]
  33. }
  34. [ansible@control plugins]$ cat addresses.yaml
  35. names:
  36. - first: anna
  37. address:
  38. city: Breda
  39. country: NL
  40. - first: denise
  41. address:
  42. city: San Francisco
  43. country: USA
  44. - first: sharon
  45. address:
  46. city: Mombasa
  47. country: kenya
  48.  
Advertisement
Add Comment
Please, Sign In to add comment