Manage Ansible Playbook for multiple environments
Please visit my website and subscribe to my youtube channel for more articles
In this blog , we will see how we can manage Ansible Playbook for multiple environments.
Problem Statement:
- How we can write the role in ansible which has to refer different values for each environment (dev,pvs,production) ? Example — database details
Solution:
- To resolve this issue,we will be using different files for each environment and pass that as a variable while running the ansible playbook.
How to do:
- Install Ansible if not already installed
- Use Ansible Roles
Create the directory structure as shown below:
- configs — This folder will have separate file for each environment which stores all the environment specific values.
- group_vars — This will have one file which is used to store all the variables which are common across environments.