Playing around with Ansible

From my experience working at Simpl.

In this article, I write my experience around debugging an issue and getting an opportunity to work with Ansible. Will highlight things at a top level. We have a service which powers our Airflow & distributed computing infra. Deployment of the service is a fairly complex process as it involves different steps. We use concourse to deploy code to the AWS infra.

Deployment pipeline of service: Concourse containers -> Bastion Servers (Ansible scripts to deploy) -> Airflow & Computing EC2 machines // 2 hop process

We can use fly intercept/set commands to access concourse containers or update pipeline config.

First issue was related to machines not being able to communicate with each other, which was fixed.

Second issue, but before that some info around Ansible:

Now coming back, what was the issue?:

As we know, the playbook uses set of secret credentials which is stored in ansible vault when it deploys the yaml file. One of the secret credentials had expired. Hence had to use the vault_pass_no_prompt key to open the ansible vault, decrypt the yaml file inside which the secret keys were kept encrypted (Note that though we say ansible vault, all the files present in the vault are present in machine only, its just that vault is just a layering on top of accessing it), change the key in yaml file, encrypt back the yaml file. These were the sequence of steps. Sample path where secret keys are stored encrypted in machine was: /deploy/ansible/inventories/keys.yml Ansible commands for encrypting/decrypting once inside the bastion machine:

source ~/.venv/ansible_env/bin/activate ## activating the env with which deployment happens to ensure changes are persisted with our manual intervention
cd /deploy/ansible/inventories ## go in the dir
ansible-vault decrypt keys.yml --vault-password-file=~/vault_pass_no_prompt ## decrypt keys which are used by playbook in running yaml steps defined in files
vi keys.yml ## make changes and save 
ansible-vault encrypt keys.yml --vault-password-file=~/vault_pass_no_prompt ## encrypt back 

So the expired key was also fixed.