Skip to main content

Ansible group_vars visible to non-members of group [Resolved]

I am using Ansible

I have inventory file like this:





I run roles from playbooks like this:

- hosts: application

  become: true

    - application

I define variables for testing environment in group_vars/testing. I have roles webproxy, database and application.

Since application group is not included in the testing group I would expect running the application role to fail because I have defined required variables only for testing group. In reality running application.yaml works it is able to use variables defined in group_vars/testing. Is that correct behaviour?

The testing group seems have at least some effect, because if I remove it completely from inventory file, then running application roles fails because of undefined variables as expected.

Are group_vars supposed to work like this? Is this maybe caused by the fact that I install roles on the same host? (I don't have access to multiple machines right now so I cannot test with each role having their own machine.)

I have been reading through Ansible documentation such as Group vars doc but have not found answer to this.

Question Credit: Madoc Comadrin
Question Reference
Asked October 11, 2017
Posted Under: Network
1 Answers

Your Answer