The host is a member of two groups. In this case, rightfully, variables are pulled from both.
This is by design -- you may select hosts based on purpose (such as webservers), while assigning other variables based on geography. On Sun, Nov 24, 2013 at 10:42 AM, Lars Vonk <[email protected]> wrote: > Hi, > > We are creating playbooks for our servers that include creating instances > with rackspace. We have problems with setting up the different inventory > files with the appropriate vars. To illustrate the problem I created a > small test case: > > DIR > ./a.yml > ./b.yml > ./test > > a.yml contains: > --- > - hosts: a > connection: local > remote_user: root > tasks: > - name: Foo > command: echo {{ hostname }} > > b.yml contains: > --- > - hosts: b > connection: local > remote_user: root > tasks: > - name: Foo > command: echo {{ hostname }} > > test contains: > localhost ansible_python_interpreter=/usr/local/bin/python > > [a] > localhost > > [b] > localhost > > [test-a:children] > a > > [test-a:vars] > hostname=a.com > > [test-b:children] > b > > [test-b:vars] > hostname=b.com > > When I run ansible-playbook a.yml -i test -vvvv it echos *b.com > <http://b.com>* while I expect *a.com <http://a.com>*. I expected this > because the hosts in a.yml is a and a is a child of test-a that defines the > hostname as *a.com <http://a.com>*. For some reason I don't understand > the hostname variable resolves to *b.com <http://b.com>*. > What we are trying to achieve with this setup is to create a rackspace > instance using a local connection (a.yml) and that add a host to the test-a > which is then used later in the playbook as host. This fails because it > resolves to the wrong hostname. > > What am I doing wrong here? Is there a better setup to achieve this? > > Thanks in advance, > Lars > > -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > -- Michael DeHaan <[email protected]> CTO, AnsibleWorks, Inc. http://www.ansibleworks.com/ -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
