I run my playbooks specifying the target server environment on the command line, e.g.:
ansible-playbook -e env=staging playbook.yml
Now I want to be able to provide parameters, e.g. dictionary of users to create on the server in such a way that there are users common to all environments, and also users that are specific to that one environment for which I run the playbook.
The directory structure could look like this:
├── group_vars
│ ├── all
│ │ ├── users.yml
│ │
│ ├── development
│ │ ├── users.yml
│ │
│ ├── production
│ │ ├── users.yml
│ │
│ └── staging
│ ├── users.yml
I initially thought that a setup like this would do the job. However, the users.yml
dictionaries for each environment are never merged with all/users.yml
ansible-playbook -e env=production playbook.yml
would just read from production/users.yml
.
How can I have Ansible merge users.yml
from specific environments with all/users.yml
- so that I always have the common and env-specific users created?