How to diff ansible vault changes?

前端 未结 4 1538
清歌不尽
清歌不尽 2020-12-07 18:08

I\'d like to see the actual git commit changes in the ansible vault file.

Is there an easy way how to achieve this?

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 18:26

    So after some digging I constructed the non-trivial solution.

    First of all store your vault password into the (.gitignored) .vault_password file.

    In the following example a HEAD and HEAD~2 versions of the file inventory/group_vars/xyz/vault.yml are vimdiff-ed:

    vimdiff \
      <(ansible-vault view --vault-password-file=.vault_password \
        <(git show HEAD:inventory/group_vars/xyz/vault.yml)) \
      <(ansible-vault view --vault-password-file=.vault_password \
        <(git show HEAD~2:inventory/group_vars/xyz/vault.yml))
    

提交回复
热议问题