I am trying to use a host variable (actually a group variable) in a
"hosts:" pattern in a playbook, but without success. Is this supposed to
work?

The use case is this: I want to write a playbook that is invoked by
passing an extra var named "target" in the command-line. The "target"
actually denotes the name of a ganeti-based cluster of virtualization
nodes, let's name it "mycluster.example.org". In the inventory there is
a group named "mycluster.example.org", which has two children groups
named "mycluster.example.org_nodes" (for ganeti nodes) and
"mycluster.example.org_instances" (for ganeti instances):

[mycluster.example.org:children]
mycluster.example.org_nodes
mycluster.example.org_instances

[mycluster.example.org_nodes]
node1.mycluster.example.org
node2.mycluster.example.org

The playbook has two plays. The first play must be run against the
master node and the other must be run against all other nodes (except
master). The master node is defined in a group variable of
"mycluster.example.org" group. So, I am trying for the first play the
following hosts pattern in the playbook, but it does not work:

- hosts: {{ hostvars[groups[target + '_nodes'][0]]['master_node'] }}

I am not sure, but it seems that hostvars/groups variables are not
available for use in hosts patterns.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/535E7492.2010304%40yahoo.gr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to