Reading a value from a file in the host_vars folder

13 views
Skip to first unread message

Johannes Kastl

unread,
Mar 24, 2016, 10:29:36 AM3/24/16
to ansible...@googlegroups.com
Hi all,

is it possible to read a value from a file located in the host_vars
folder, if this is not the host the play should run on?

I am trying to convert a script creating a lxc container on host foo
to an ansible playbook. But instead of calling the role with lots of
variables (container name, user name, password, ...) I wanted to
define them in the host_vars file for the container, as I would need
it a little later anyway.

Any hints?

Johannes

signature.asc

Johannes Kastl

unread,
Mar 24, 2016, 10:34:40 AM3/24/16
to ansible...@googlegroups.com
Reply to self...

Am 24.03.16 schrieb Johannes Kastl:

> is it possible to read a value from a file located in the host_vars
> folder, if this is not the host the play should run on?

Yes, *if* the host new-host is added to the inventory before trying to
get its variables.

- debug: var=hostvars['new-host']['ansible_user']

Johannes

signature.asc
Reply all
Reply to author
Forward
0 new messages