List in inventory file variables ?

Hi,

I would like to write a complex variable (list) for each host in my inventory file.
I know it’s not a best practice, but I cannot write a vars file per host (constrained by project).

So I tried something like this :

[my-hosts]
192.168.0.161 pub=[{ip:‘192.168.0.162’,proto:‘tcp’},{ip:‘192.168.0.163’,proto:‘tcp’}]

But it does not seem to work, I cannot use it in with_indexed_items for example. Variable seems to be treated as a string.
It returns “with_indexed_items expects a list”.

How can I do ?

I use Ansible 1.8.4

Thank you a lot.

​Don't define complex vars in the ini hosts file, use group/host_vars file​
or playbook vars for that.

If you have to generate exactly one file, you can try creating a dynamic inventory

Florent B florent@coppint.com napisał: