Just put your group_vars directory in the same directory as the
inventory script.
./ec2.py
./group_vars/<name_of_group>
./group_vars/<name_of_other_group>
(Do not add a ".yml" extension on the name of the group)
Just put your group_vars directory in the same directory as the
inventory script.
./ec2.py
./group_vars/<name_of_group>
./group_vars/<name_of_other_group>
(Do not add a ".yml" extension on the name of the group)
I’m having trouble exposing group_vars on an end node that is part of a group defined by an ec2 instance tag.
from inside my ‘staging’ directory:
[david@ops-1 staging{master}]$ ls
ansible.cfg inventory
[david@ops-1 staging{master}]$ cat ansible.cfg
[defaults]
hostfile = inventory/ec2.py
inventory directory contains another sub directory: groups_vars which contains: tag_mogilefsd_1
i can prove that a node matches on that group:
david@ops-1 staging{master}]$ ansible -m ping tag_mogilefsd_1
10.100.1.45 | success >> {
“changed”: false,
“ping”: “pong”
}
and yet using the setup module to dump variables on the end node, i don’t see the contents of inventory/group_vars/tag_mogilefsd_1
Hmm,
There should be nothing here that is ec2 specific.
Can you show me the output of “tree” on your inventory directory just so I can see everything?
Also can you tell me what version of ansible you are using? Older versions did not load group_vars/host_vars into “ad-hoc” /usr/bin/ansible and only worked in playbooks.
My other thought is maybe there’s an error in your group_vars file.
Hmm,
There should be nothing here that is ec2 specific.
Can you show me the output of “tree” on your inventory directory just so I can see everything?
https://gist.github.com/davidbirdsong/5667411
Also can you tell me what version of ansible you are using? Older versions did not load group_vars/host_vars into “ad-hoc” /usr/bin/ansible and only worked in playbooks.
I call it ansible-1.2 for rpm building-sake:
[david@ops-1 ansible{devel}]$ git log -n 1 --format=format:%H
753ebea186d93f5f26ec394bd6ec3fbdca43e2d5
Can you show me what you are using to get the value of master_db_server out?
Maybe it’s something subtle in there instead?
Can you show me what you are using to get the value of master_db_server out?
Maybe it’s something subtle in there instead?
[david@ops-1 staging{master}]$ ansible -m setup tag_mogilefsd_1 | grep -i master
[david@ops-1 staging{master}]$
am i doing it wrong?
Oh that.
Yes.
The setup module returns facts that ansible discovered (built in stuff), but it doesn’t return variables you have set.
Create a playbook and try the ‘debug’ module or use the ‘template’ module and {{ varname }} and you should see it fine.
Oh that.
Yes.
The setup module returns facts that ansible discovered (built in stuff), but it doesn’t return variables you have set.
Create a playbook and try the ‘debug’ module or use the ‘template’ module and {{ varname }} and you should see it fine.
yep, that was it.
great, thanks for the clarification and reminding me to use the debug module. it should come in handy.