Question with group_vars

55 views
Skip to first unread message

Samnang Sen

unread,
May 20, 2014, 2:43:22 PM5/20/14
to ansible...@googlegroups.com
In my local.yml I'm able to run the playbook and reference variables within group_vars/all however I'm not able to access variables within group_vars/phl-stage. Let's assume the following.

ansible-playbook -i phl-stage site.yml

I have a variable, let's call it "deploy_path" that's different for each environment. I place the variable within group_vars/<environment name>. If I include the file (group_vars/phl-stage) within "vars_files" it works but I would've thought the group file would be automatically loaded?


# cat local.yml
---
# file: local.yml

- hosts: 127.0.0.1
  connection: local

  vars_files:
    - "group_vars/perlservers"
    - "group_vars/deploy_list"


# cat phl-stage
---
[webservers]
phl-web1
phl-web2

[perlservers]
phl-perl1
phl-perl2

[phl-stage:children]
webservers
perlservers


Directory structure:

group_vars
    all
    phl-stage
    phl-prod
site.yml
local.yml


Michael DeHaan

unread,
May 21, 2014, 6:08:43 PM5/21/14
to ansible...@googlegroups.com
You never need to include group_vars/<groupname> variables in vars_files -- these are loaded automatically.   Ditto for host_vars/<hostname>.

The paths looked at those alongside your playbook or inventory.

If you want to put them somewhere else, you can be explicit, but I would not call them "group_vars" as that means something in ansible and might confuse anyone reading it why you had the duplication.




--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a1142fa4-336b-48de-85dc-96a982d5219d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages