Resolve merge conflicts in ansible vault
When you use ansible vault in your project, sometimes merge conflicts would occur across divergent branches that make changes to the encrypted file. Below is a simple process to identify and resolve merge conflicts introduced in an ansible vault file. Step 1: Decrypt the vault For each of the divergent branches, decrypt the vault so that you can have a readable text file git checkout master git pull ansible-vault decrypt secrets-file git commit -am "decrypting vault to better handle merge conflicts" git checkout my-new-branch git pull ansible-vault decrypt secrets-file Step 2: Start Merge operation You can now attempt to merge one branch into the other based on your preferred strategy git merge master Auto-merging secrets-file CONFLICT (content): Merge conflict in secrets-file Automatic merge failed; fix conflicts and then commit the result. Open your favourite IDE and resolve the merge conflicts presented Complete the merge git add secrets-file git commit -m "Resolved merge conflicts" Step 3: Clean up Now that you have resolved your merge conflicts locally, encrypt the update secret file ansible-vault encrypt secrets-file And clean up your other branch git checkout master git reset --hard origin/master Encrypt Step 4: Push to remote(optional) If done working on your branch, you can push all your merged changes to remote git checkout my-new-branch git push

When you use ansible vault in your project, sometimes merge conflicts would occur across divergent branches that make changes to the encrypted file. Below is a simple process to identify and resolve merge conflicts introduced in an ansible vault file.
Step 1: Decrypt the vault
For each of the divergent branches, decrypt the vault so that you can have a readable text file
git checkout master
git pull
ansible-vault decrypt secrets-file
git commit -am "decrypting vault to better handle merge conflicts"
git checkout my-new-branch
git pull
ansible-vault decrypt secrets-file
Step 2: Start Merge operation
You can now attempt to merge one branch into the other based on your preferred strategy
git merge master
Auto-merging secrets-file
CONFLICT (content): Merge conflict in secrets-file
Automatic merge failed; fix conflicts and then commit the result.
Open your favourite IDE and resolve the merge conflicts presented
Complete the merge
git add secrets-file
git commit -m "Resolved merge conflicts"
Step 3: Clean up
Now that you have resolved your merge conflicts locally, encrypt the update secret file
ansible-vault encrypt secrets-file
And clean up your other branch
git checkout master
git reset --hard origin/master
Encrypt
Step 4: Push to remote(optional)
If done working on your branch, you can push all your merged changes to remote
git checkout my-new-branch
git push