Use hostnames from ansible group into template

61 views
Skip to first unread message

Petr Sukharev

unread,
Mar 11, 2014, 1:21:38 AM3/11/14
to ansible...@googlegroups.com
Hi!
Does anybody know solution for scenario like this:
i have template (sudoers file with host list) like this

Host_group = host1, host2, host3
Host_group = host4, host5, host6
Host_group = host7, host8, host9

And host file like this:
[app]
host1
host2
host3

[db]
host4
host5
host6

[other]
host7
host8
host9

How can i use variable with host list from hosts file? Like this:

Host_group = {{  app }}
Host_group = {{  db }}

I add some host in hosts file and it will be automatically insert into this variable. Does it real?


Tomasz Leśniewski

unread,
Mar 11, 2014, 4:09:01 AM3/11/14
to ansible...@googlegroups.com
You mean:

Host_group = {{  groups['app'] | join(',') }}
Host_group = {{  groups['db'] | join(',') }}

?

Petr Sukharev

unread,
Mar 11, 2014, 6:37:48 AM3/11/14
to ansible...@googlegroups.com
Exactly! Thanks for you help.

вторник, 11 марта 2014 г., 12:09:01 UTC+4 пользователь Tomasz Leśniewski написал:
Reply all
Reply to author
Forward
0 new messages