I've seen others post similar experiences, but I can never quite get my 
head around it. If someone could explain the following behaviour that would 
be great.

So i have mydev.yml and mylive.yml

They look something like:

mydev.yml
- hosts: dev_place
  sudo: no 


mylive.yml
- hosts: live_place
  sudo: no 



hosts
[dev_place]
10.10.10.10

[dev_place:vars]
ansible_private_key_file=/home/dev_user/.ssh/key

[live_place]
10.10.10.10

[live_place:vars]
ansible_private_key_file=/home/live_user/.ssh/key


Both hosts point to the same server but reference different paths for their 
keys. This is because I can run locally on my vagrant or run it on a live 
server - both need to talk to the same server.

So I run this locally:
ansible-playbook mydev.yml-i hosts -vvv

>From the printout, I can see it is using live_place vars

I've tried removing the :vars from here, and adding:
group_vars.dev_place.yml
group_vars.live_place.yml

So then these would have the relative variables, but again it would be 
using which ever hosts are listed last.

So if I swap dev_place and live_place around in the hosts file, it will 
then take dev_place vars.

I know ansible has a specific way of how it deals with vars, but I'm really 
struggling to understand.
What's the point of passing a config name if it's just going to grab the 
last vars from somewhere else....?

I apologise for my misunderstanding on this stuff.


-- 
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/84efaf80-9b81-41ca-b134-824ebb5b27cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to