I'm trying to figure out what is the best strategy to use custom variables on my ansible-playbooks/ansible-roles. What I'm doing is at this time is:
Customer1:
- Create a new inventory file with Customer1 devices on
inventories/customer1.ini
- Overwrite customer variables on
vars/controls.yml
- Execute my ansible-playbook/ansible-role for Customer1
ansible-playbook -i inventories/customer1.ini site.yml
Customer2:
- Create a new inventory file with Customer2 devices on
inventories/customer2.ini
- Overwrite customer variables on
vars/controls.yml
- Execute my ansible-playbook/ansible-role for Customer2
ansible-playbook -i inventories/customer2.ini site.yml
Customer N:
What I want to do, is just create a different variables controls vars/controls.yml
per customer:
vars/controls-customer1.yml
vars/controls-customer2.yml
And that my ansible-playbook/ansible-role is able to read it without any change (reusability).
I hope you can give me some light on this.
Thank you!
inventories/customerX/hosts.ini
and put your customer vars ininventories/customerX/group_vars/all.yml
. You will not have to overwrite anything and vars will be loaded automagically for any hosts in your inventory. – Zeitounator-i inventories/customerX
option will be enough. docs.ansible.com/ansible/latest/user_guide/… – Zeitounator