Skip to main content

ansible-vault-keyring

A simple tool to get and set passwords for ansible vaults using the system keyring.

Installation

Install ansible-vault-keyring using your favorite package manager / method.

For me, using uv I use.

uv tool install ansible-vault-keyring

Usage

Setting a password.

$ ansible-vault-keyring --vault-id my_vault_id --set
Enter password   : foo 
Confirm password : foo

Getting a password.

$ ansible-vault-keyring --vault-id my_vault_id
foo

Recommend usage.

If for example, you want to use the ansible-vault-keyring tool to get two passwords from your keyring, one for a global vault-id, and one for a personal vault-id, you can add this to your ansible.cfg file.

[defaults]
vault_identity_list = global@/path/to/ansible_vault_keyring, personal@/path/to/ansible_vault_keyring

If like me you install with uv, you will find the binary in whatever bin directory it uses, and you should refer to that uv documentation to find the path to the standalone executable. For me this is ~/.local/bin/ansible-vault-keyring, and I have ~/.local/bin in my PATH environment variable.

Now when a password is needed by ansible, it will invoke the ansible-vault-keyring tool to get the password from the keyring.

How Ansible finds config files

Ansible will load settings from the first ansible.cfg file it finds from :-

  1. The file in the ANSIBLE_CONFIG environment variable.
  2. The file ansible.cfg file in the current working directory.
  3. The file ~/.ansible.cfg file (in the user's home directory).
  4. The file /etc/ansible/ansible.cfg file (in the system ansible config directory).

Security Considerations.

The file is stored in the system keyring, for example gnome-keyring or OSX-Keychain. It does this using the keyring python package.

This means that the password is stored in plain text in the system keyring, and can be read by anyone with access to the system keyring, but this is true for all passwords stored in a system keyring.

Additionally, the password is passed through the python process running the ansible-vault-keyring tool.

However in reality this is likely to be at least as secure as copying+pasting the passwords from a password manager, and will certainly be better than reusing a password, or writing it on a post it note stuck to your monitor.

Credits

This tool was heavily inspired by vault-keyring-client.py from ansible-community's contrib scripts.

It is either a rewrite or a fork depending on your take, and thus I consider it a derivative work. See the LICENSE file for details of the original authors of vault-keyring-client.py.

Metadata

Release files for ansible-vault-keyring 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansible-vault-keyring 0.2.0
File Size Uploaded Provenance Actions
ansible_vault_keyring-0.2.0.tar.gz 34.5 kB Without provenance Details for ansible_vault_keyring-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ansible-vault-keyring 0.2.0
File Interpreter ABI Platform Actions
ansible_vault_keyring-0.2.0-py3-none-any.whl Python 3 none any Details for ansible_vault_keyring-0.2.0-py3-none-any.whl

Total release size: 51.5 kB

Release files / ansible_vault_keyring-0.2.0.tar.gz

Download URL ansible_vault_keyring-0.2.0.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4f97bbd2e06bb331d8f12ef665040a7db102fd153cf13c0b94c67e8d3d411fc2
BLAKE2b-256 checksum
How to use checksums
8e0d61e4cf4bbd4641029946212f3676135feb05c3162e62b1656814a3b1e83f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.0

Release files / ansible_vault_keyring-0.2.0-py3-none-any.whl

Download URL ansible_vault_keyring-0.2.0-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51d4c0c6be761924d68c8dfb316af48896641d4ebfbe6e543b65335a1739914a
BLAKE2b-256 checksum
How to use checksums
3680224379fd7de7ac259eadf93edede2c4b1456d81cf7843b96e06d0199deec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.0

Security for ansible-vault-keyring 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page