How to automate bash profile deployment 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:
- Create separate inventory files file each environment.
- Create a ansible role to manage all bashrc files related task.
- Keep all environment specific configuration in inventory vars.
- Create template if you have fixed set of variable and write the bashc file based on the environment.
- Write down all back file and deployment tasks in tasks/main.yaml.
Method 2:
- Create separate inventory file for each environment
- Create a separate role in Ansible . eg. bashrcdeployment
- Save all environment users config in roles/bashrcdeployment/files/main.yaml. e.g PROD/user1/.bashrc_profile , /PROD/user2/.bashrc_profile
- In roles/bashrcdeployment/default/main.yaml section, keep all environment and users details.
- Write down all back and deployment tasks in roles/bashrcdeployment/tasks/main.yaml
(Visited 554 times, 132 visits today)