Advanced Python CLI to rotate the secret used for ansible vault inline secrets and files in a project
- Reencrypt vault files
- Reencrypt inline vaulted secrets
It is strongly recommended to use pipx instead of pip if possible:
pipx install ansible-vault-rotate
Otherwise you can also use plain pip, but be warned that this might collide with your ansible installation globally!
pip install ansible-vault-rotate
ansible-vault-rotate --old-vault-secret-source file://my-vault-password \
--new-vault-secret-source my-new-secret \
--update-source-secret
ansible-vault-rotate --old-vault-secret-source file://my-vault-password-<stage> \
--new-vault-secret-source my-new-secret \
--file-glob-pattern group_vars/<stage>/*.yml \
--update-source-secret
ansible-vault-rotate --help
For development, you will need:
- Python 3.9 or greater
- Poetry
poetry install
poetry run pytest