Ansible Vault Tools
A simple CLI tool and Python library to encrypt and decrypt strings and files using Ansible Vault, and to inspect decrypted host variables from an Ansible inventory.
Requirements
- Python 3.11 or newer
ansibleandansible-vaultexecutables available inPATH(provided by theansibleandansible-vaultpackages)
Installation
Install with the optional Ansible dependencies included:
pip install "ansible-vault-tools[ansible-deps]"
Or, if you manage Ansible separately:
pip install ansible-vault-tools
Usage
CLI
ansible-vault-tools <command> [options]
encrypt — encrypt a string or file
# Encrypt a string (prompts for input if omitted)
ansible-vault-tools encrypt --string "my secret"
ansible-vault-tools encrypt -s
# Encrypt a file in place
ansible-vault-tools encrypt --file secrets.yml
ansible-vault-tools encrypt -f secrets.yml
decrypt — decrypt a variable or file
# Decrypt a specific variable for a host (prompts if omitted)
ansible-vault-tools decrypt --host webserver01 --var db_password
ansible-vault-tools decrypt -H webserver01 -v db_password
# Decrypt variables for all hosts
ansible-vault-tools decrypt --host all --var db_password
# Decrypt a vault-encrypted file (shows content, then asks to write it back)
ansible-vault-tools decrypt --file secrets.yml
ansible-vault-tools decrypt -f secrets.yml
allvars — print all variables for a host
# Print all resolved variables for a specific host
ansible-vault-tools allvars --host webserver01
ansible-vault-tools allvars -H webserver01
# Print hostvars for all hosts
ansible-vault-tools allvars --host all
Library
The individual functions can also be imported directly:
from ansible_vault_tools.main import (
encrypt_string,
encrypt_file,
decrypt_string,
decrypt_file,
allvars,
)
| Function | Description |
|---|---|
encrypt_string(password) |
Encrypt a string with ansible-vault encrypt_string |
encrypt_file(filename) |
Encrypt a file in place with ansible-vault encrypt |
decrypt_string(host, var) |
Decrypt a variable from Ansible inventory host(s) |
decrypt_file(filename) |
Decrypt a vault-encrypted file |
allvars(host) |
Return all variables for a host as JSON |
License
The project is mainly licensed under Apache-2.0. It may also contain files under different licenses and copyright holders. The project is REUSE compliant so it's fully transparent.
Metadata
Release files for ansible-vault-tools 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ansible_vault_tools-0.2.7.tar.gz | 13.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ansible_vault_tools-0.2.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.2 kB
Release files / ansible_vault_tools-0.2.7.tar.gz
| Download URL | ansible_vault_tools-0.2.7.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96b5171bdd0ae6a74a6fcf0e3b5543f35df75e3973e08c1c1ee77692f84660a3
|
|
BLAKE2b-256 checksum How to use checksums |
7d4ae7ad6f2b4a06d7ad82c5e584dabe8ae6c8f4d8a184bd56713bbe6e7566d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / ansible_vault_tools-0.2.7-py3-none-any.whl
| Download URL | ansible_vault_tools-0.2.7-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ece3d55a8504b1fab2dd386db438a58bcda44cb10b641a921242b1bf226bc199
|
|
BLAKE2b-256 checksum How to use checksums |
07001a0ffdc75bfb5baa89234bf8778fb6256ec08dc200b74254a5d44f81dde6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logSecurity for ansible-vault-tools 0.2.7
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ansible_vault_tools-0.2.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logA 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.