Member-only story

Check The Difference Between Files Encrypted With Ansible-Vault With Git Diff.

Maciej
1 min readSep 21, 2020

--

Introduction

git diffwill explain how to make the difference of the encrypted file in ansible-vault visible in.

Allows you to view vault files without a password

Create file ./ansible.cfgin the project home directory.

# Specify the path of the file that stores the ansible-vault password
[defaults]
vault_password_file = ./.vault_password

Create a file to store the password (here .vault_password)

somestrongpassword123

Add the password file to to prevent accidental commits to the repository in .gitignore

.vault_password

Set the text converter for vault files to ansible-vault

  • .git/configOr ~/.gitconfigadd the following description.
[diff "ansible-vault"]
textconv = ansible-vault view
cachetextconv = true
  • Specify the path of the vault file
# *-vault.yml * .vault.yml can also be specified with wildcard
sample.vault.yml diff = ansible-vault merge = binary

Check file differences

Now, git diffin you will be able to see the differences of the vault file.

$ git diff
diff --git i/sample.vault.yml…

--

--

Maciej
Maciej

Written by Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

No responses yet