Example 5
hosts.yml
centos:
hosts:
provisioner:
ansible_connection: local
centos1:
ansible_host: '192.168.77.22'
ubuntu:
hosts:
ubuntu1:
ansible_host: '192.168.77.23'
playbook.yml
- name: Example playbook
hosts: centos1
gather_facts: false
vars:
list1_alternate:
[ value1, value2, value3 ]
tasks:
- name: This is a list
debug:
msg: "{{ list1_alternate }}"
- name: Accessing the values using the Python syntax
debug:
msg: "{{ list1_alternate[0] }}"
- name: Accessing the values using the dot notation
debug:
msg: "{{ list1_alternate.0 }}"
Tip
List
type variables can also be represented in an alternate fashion.
Execute the following command
ansible-playbook playbook.yml