Simple library and CLI tool to deal with ansible vaults and encrypted strings
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ansible_vault_tools-0.2.1.tar.gz.
File metadata
- Download URL: ansible_vault_tools-0.2.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c510c79b78d6ea3cc46e8898dc54454a0294ce64fe03db89c7a984210a05d217
|
|
| MD5 |
5d635932f560916c657b7fa938c24590
|
|
| BLAKE2b-256 |
897bda8d8d9db671497743a6c7d78fb47a79ec472816ccf181c8d1d0cbe01989
|
Provenance
The following attestation bundles were made for ansible_vault_tools-0.2.1.tar.gz:
Publisher:
publish.yaml on mxmehl/ansible-vault-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ansible_vault_tools-0.2.1.tar.gz -
Subject digest:
c510c79b78d6ea3cc46e8898dc54454a0294ce64fe03db89c7a984210a05d217 - Sigstore transparency entry: 1340623141
- Sigstore integration time:
-
Permalink:
mxmehl/ansible-vault-tools@03e65f93f0c8d72ee5794c94afc2bd8f9bb4ca9d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mxmehl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@03e65f93f0c8d72ee5794c94afc2bd8f9bb4ca9d -
Trigger Event:
release
-
Statement type:
File details
Details for the file ansible_vault_tools-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ansible_vault_tools-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d79153010b69a2b7e6faf372df9a078b7cb1014632dcc381ce741feecc54553
|
|
| MD5 |
4ea01f3b706b3b4c67d230cab35a8ad3
|
|
| BLAKE2b-256 |
92993475a00ae9773e154ce037ff7a84b3963b48f43587db5c37fb37c506c19e
|
Provenance
The following attestation bundles were made for ansible_vault_tools-0.2.1-py3-none-any.whl:
Publisher:
publish.yaml on mxmehl/ansible-vault-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ansible_vault_tools-0.2.1-py3-none-any.whl -
Subject digest:
0d79153010b69a2b7e6faf372df9a078b7cb1014632dcc381ce741feecc54553 - Sigstore transparency entry: 1340623159
- Sigstore integration time:
-
Permalink:
mxmehl/ansible-vault-tools@03e65f93f0c8d72ee5794c94afc2bd8f9bb4ca9d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mxmehl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@03e65f93f0c8d72ee5794c94afc2bd8f9bb4ca9d -
Trigger Event:
release
-
Statement type: