Nidhi
2 min readOct 23, 2018

--

Manage Ansible Playbook for multiple environments

Please visit my website and subscribe to my youtube channel for more articles

https://devops4solutions.com/

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:

  1. Install Ansible if not already installed
  2. Use Ansible Roles

Create the directory structure as shown below:

  1. configs — This folder will have separate file for each environment which stores all the environment specific values.
  2. group_vars — This will have one file which is used to store all the variables which are common across environments.

--

--

Nidhi
Nidhi

Written by Nidhi

Devops Automation Enginneer

Responses (1)