bumelant
(bumelant)
February 20, 2015, 12:16pm
1
Hi everyone,
Is it possible to use variables in hosts: name, like so:
name: This does not work
hosts: “security_group_{{ cluster_name }} ”
roles:
my-cluster
The variable {{ cluster_name }} is defined in my-cluster variables and is generally accessible. Not from the hosts: section though.
Thanks,
Maciej
Brian_Coca
(Brian Coca)
February 20, 2015, 1:00pm
2
You CAN use variables for hosts: but not from inventory as you need
to load hosts: to get the appropriate data.
also it would be:
hosts: "{{ 'security_group_' + cluster_name }}"
bumelant
(bumelant)
February 20, 2015, 6:17pm
3
Hi Brian,
It did work as you wrote, thanks! I had to pass the variables form the command line with -e, as the variables I’ve tried to use before pulled from roles. Need to figure out a way to pull these to the playbook level apparently.
Regards,
Maciej
Brian_Coca
(Brian Coca)
February 20, 2015, 6:23pm
4
no way, pretty much extra-vars are only one you have available at that point