hostvars with variables for different hosts

33 views
Skip to first unread message

Roman Belyakovsky

unread,
Oct 2, 2015, 5:08:56 AM10/2/15
to Ansible Project
Hello!

Let's say I have a simple dictionary in host_vars or group_vars:
host_presets:
 hostname: "{{ inventory_hostname.split('.')[0] }}
 domain: "
{{ inventory_hostname| regex_replace('^' + inventory_hostname.split('.')[0] + '\\.', '')}}"

It works perfectly till I try to get it for other host with hostvars['myvm'].host_presets.hostname. In this case I get the hostname of the server that runs a playbook.

Is there a working way for dynamic predefining this kind of host/group vars?

Regards,
Roman

Roman Belyakovsky

unread,
Oct 12, 2015, 2:19:32 PM10/12/15
to Ansible Project
FYI, opened an issue.
Reply all
Reply to author
Forward
0 new messages