fatal: [localhost]: FAILED! => {
“msg”: "The task includes an option with an undefined variable. The error was: ‘list object’ has no attribute ‘keys’…}
just to make sure - this is a list of list of dictionaries.
If this is your source of truth, and you intend to have a list of dicts, then it could look like this:
domain_definition:
name: server11
cluster: cluster1
port: ‘8080’
name: server12
cluster: cluster2
port: ‘8090’
name: server21
cluster: cluster3
port: ‘9080’
name: server22
cluster: cluster4
port: ‘9090’
This will make a difference when manipulating the data.
the way the variables are defined: the inventory file is not a yaml file (ini format). Refer to this post for how to define your dictionary(ies) in the hosts file.
The second statement is correct only if you refer to the host file (defaults to /etc/ansible/host). The inventory for
your playbook can be written completely in YAML.