-1

I'm running ansible 2.6.4 on python 2.7.5. This is my directory structure:

inventory/all
group_vars/all.yml
group_vars/lab.yml
playbook.yml
...

This is my inventory/all:

[lab]
localhost

all.yml contains a bunch of defaults, lab.yml has a few overrides. In particular, a repo URL is different. When I run the playbook with ansible-playbook -i /workspace/inventory/all -c local --diff -v /workspace/local.yml, the vars in group_vars/lab.yml are never loaded. Note that I'm running the command from somewhere other than /workspace. If I add -e @group_vars/lab.yml, the vars are loaded the playbook runs as it should.

I wouldn't normally care that much, and simply run commands with -e @group_vars/lab.yml, except that I'm attempting to get these playbooks running in AWX, which presents the same vars-not-loading behavour.

edit

came back to this with fresh eyes. playbook had vars_files: [group_vars/all.yml] in it. removed that and all was right with the world.

shaun m
  • 440
  • 1
  • 5
  • 15
  • 2
    Have you already tried placing the `group_vars` inside the `inventory` directory? That's the setup that I have the most experience using. Also, I think you mean `-e @group_vars/lab.yml`, right, not `-i`? – mdaniel Sep 20 '18 at 01:29
  • @MatthewLDaniel I have tried moving group_vars into the inventory directory, but it yields the same results. Also thanks for the `i` vs `e` headsup. – shaun m Sep 20 '18 at 14:43

1 Answers1

0

PEBKAC. playbook had vars_files: [group_vars/all.yml] in it. removed that and all was right with the world.

shaun m
  • 440
  • 1
  • 5
  • 15