Skip to main content

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
  • ansible and ansible-vault executables available in PATH (provided by the ansible and ansible-vault packages)

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansible_vault_tools-0.2.6.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansible_vault_tools-0.2.6-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file ansible_vault_tools-0.2.6.tar.gz.

File metadata

  • Download URL: ansible_vault_tools-0.2.6.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ansible_vault_tools-0.2.6.tar.gz
Algorithm Hash digest
SHA256 670a560d2946b8a2406dcfa866110b2d4fbffadc4fd9ce5e917d2aba45267e08
MD5 aac06a359c6b9de59cce462374059571
BLAKE2b-256 981d72fff4cfe806b1bdacbe3724cf0a2f6502c347e89b3431b19023389aade5

See more details on using hashes here.

Provenance

The following attestation bundles were made for ansible_vault_tools-0.2.6.tar.gz:

Publisher: publish.yaml on mxmehl/ansible-vault-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ansible_vault_tools-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for ansible_vault_tools-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 65a5835c8f769f76ba156df675b143b26f3333cf385b28fac337d1c0e2deb472
MD5 418dfaf7caec92b44951db2a70e461ee
BLAKE2b-256 4b62f76865c527eb9f4e764a871882fe77240720785ecc9b587b49c15fc6dcde

See more details on using hashes here.

Provenance

The following attestation bundles were made for ansible_vault_tools-0.2.6-py3-none-any.whl:

Publisher: publish.yaml on mxmehl/ansible-vault-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

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