List in inventory file variables ?

94 views
Skip to first unread message

Florent B

unread,
Feb 26, 2015, 7:08:53 AM2/26/15
to ansible...@googlegroups.com
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.

Serge van Ginderachter

unread,
Feb 26, 2015, 7:15:35 AM2/26/15
to ansible...@googlegroups.com

On 26 February 2015 at 13:08, Florent B <flo...@coppint.com> wrote:
How can I do ?


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


Tomasz Kontusz

unread,
Feb 27, 2015, 3:20:33 AM2/27/15
to ansible...@googlegroups.com
If you have to generate exactly one file, you can try creating a dynamic inventory

Florent B <flo...@coppint.com> napisał:

--
Wysłane za pomocą K-9 Mail.
Reply all
Reply to author
Forward
0 new messages