Lists & Dictionary YAML Syntax by example
fruits:
- Apple
- Orange
- Strawberry
- Mango
{"fruits":["Apple","Orange","Strawberry","Mango"]}
- debug: msg='fruit name {{item}}'
with_items: fruits
- debug: msg='fruit name {{item}}'
with_items: fruits
[{"debug":"msg='fruit name {{item}}'","with_items":"fruits"},{"debug":"msg='fruit name {{item}}'","with_items":"fruits"}]
instructions:
- name: server1
subject: pepito
- name: server2
subject: juanito
{"instructions":[{"name":"server1","subject":"pepito"},{"name":"server2","subject":"juanito"}]}
- command: path={{ item.name }} mode={{ item.subject }}
with_items: instructions
- martin:
name: Martin D'vloper
job: Developer
skill: Elite
- john:
name: John D'vloper
job: PM
skill: Elite
[{"martin":{"name":"Martin D'vloper","job":"Developer","skill":"Elite"}},{"john":{"name":"John D'vloper","job":"PM","skill":"Elite"}}]
employees:
- martin: {name: Martin D'vloper, job: Developer, skill: Elite}
- john: {name: John D'vloper, job: PM, skill: Elite}
- prod_list:
- prod_name: "unknown product"
prod_serial: "123456"
prod_location: /opt/product1"
- prod_name: "popular product"
prod_serial: "987654"
prod_location: /opt/product2"
- debug: msg="product name {{item.prod_name}} serial {{item.prod_serial}} location {{item.prod_location}}"
with_items: prod_list