how to automate bashrc file in ansible

If you dealing with number of servers in day to day basis and if your application is growing rapidly then you may come across with different environment variable which you have to update manually bashrc files. What if you have 10+ environment then it will difficult for you to update the bash profile file manually.

How to automate bashrc file deployment?

You can automate your bash profile deployment using Ansible. Here is my preferred way to achieve this.

Method 1:

  1. Create separate inventory files file each environment.
  2. Create a ansible role to manage all bashrc files related task.
  3. Keep all environment specific configuration in inventory vars.
  4. Create template if you have fixed set of variable and write the bashc file based on the environment.
  5. Write down all back file and deployment tasks in tasks/main.yaml.

Method 2:

  1. Create separate inventory file for each environment
  2. Create a separate role in Ansible . eg. bashrcdeployment
  3. Save all environment users config in roles/bashrcdeployment/files/main.yaml. e.g PROD/user1/.bashrc_profile , /PROD/user2/.bashrc_profile
  4. In roles/bashrcdeployment/default/main.yaml section, keep all environment and users details.
  5. Write down all back and deployment tasks in roles/bashrcdeployment/tasks/main.yaml
(Visited 554 times, 132 visits today)