0

I'm trying to use my first playbook with a galaxy role and while I can get the role to run, I can't seem to get it to find the group_vars I've defined.

The role is nickjj.mariadb (not that that probably matters) but in the docs its stated that group_vars should be relative to your inventory directory.

I've tried a couple of different things but so far no dice.

tree                                                                                                                                                             
 .
 ├── group.vars
 │   └── siteservers.yml
 ├── install_maria.yml
 ├── inventory
 │   └── hosts
 └── update-apt.yml

is what I have for the layout and I'm running the playbook with

ansible-playbook -i inventory/hosts -l siteservers install_maria.yml -K

It is finding the ip address of the server from the hosts file happily, but doesn't seem to pick up the variables from siteservers.yml.

Where should this be put? Am I close with the layout or is it all wrong?

Peter Nunn
  • 432
  • 1
  • 10
  • 24

2 Answers2

0

You have a typo in your directory name: group.vars

This should have an underscore, not a full stop: group_vars

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
0

Try setting the PLAYBOOK_VARS_ROOT parameter to the path of the playbook so Ansible can find the group_vars directory. Or set the value to bottom

This sets which playbook dirs will be used as a root to process vars plugins, which includes finding host_vars/group_vars The top option follows the traditional behaviour of using the top playbook in the chain to find the root directory. The bottom option follows the 2.4.0 behaviour of using the current playbook to find the root directory. The all option examines from the first parent to the current playbook.

Henrik Pingel
  • 8,676
  • 2
  • 24
  • 38