Dear List,
We have a program running under different acounts on one server. (Sometimes two server share the load of 1 environment)
Each program/account combination has it’s own settings, IP ports, etc.
This part is all fine and we want to take care of those settings using ansible.
So we came up with this:
Each environment needs it’s own settings, so:
“/etc/ansible/hosts”
[env1]
taixkaren[env2]
taixkaren
taixkitty
[env3]
taixkaren
[env4]
taixkaren
[env5]
taixkaren
peibapril
And then some group_vars files to set the individual environment settings:
“/etc/ansible/group_vars/env1”
program:
setting1: epplus
setting2: 8080
“/etc/ansible/group_vars/env2”
program:
setting1: userepenv
setting2: 86735eib:
sets: “4,6,02”
etc for the other groups.
The main playbook looks like this:
- hosts: $omgeving
sudo: true
vars_files:- /etc/ansible/group_vars/$omgeving
tasks:
- include: $basedir/europort/ep_stop_start/tasks/finttpci_stop.yml
when: program is defined- include: $basedir/europort/ep_stop_start/tasks/fintexch_stop.yml
when: eib is defined- include: $basedir/europort/ep_stop_start/tasks/fintbpo_stop.yml
Do you notice that “- /etc/ansible/group_vars/$omgeving” line? remember it…
To start this playbook, I do this:
ansible-playbook europort/europort.yml --extra-vars “omgeving=env2”
So far so good.
Now let’s try two environments:
ansible-playbook europort/europort.yml --extra-vars “omgeving=env2:env4”
This goes wrong because ansible tries to import “/etc/ansible/group_vars/env2:env4” which ofcourse does not exist.
But when I do not put in that line “/etc/ansible/group_vars/$omgeving” it may actually load the settings for env3 in memory instead of env2 even though I only wanted to target env2!
Are we going about this the wrong way entirely?
Thoughts much appreciated!