rvault
A tool to encrypt or decrypt JSON or YAML files that contain partial Ansible vault encrypted values.
This is a Rust port from here: https://github.com/OkieOth/partial-vaults/tree/main
Overview
rvault allows you to work with files that have a mix of plain text and Ansible Vault encrypted values. Unlike standard Ansible Vault which encrypts entire files, this tool lets you:
- Encrypt specific values within JSON or YAML files
- Decrypt specific values while leaving others encrypted
- Process nested structures with selective encryption
- Interactively edit encrypted values in-place
- Copy decrypted values to the clipboard with auto-clear
Install
# install from crates.io
# use
Usage
rvault has four subcommands: encrypt, decrypt, edit, and clip.
Password resolution
All subcommands need a vault password. It is resolved in this priority order:
--password <PASSWORD>— pass the password directly on the command line--pfile <FILE>— read the password from a fileMY_RVAULT_PWDenvironment variable — path to a password file
# inline password
# password from file
# password from environment (recommended for scripts)
Output target
For encrypt, decrypt, and edit, exactly one output option must be given:
| Flag | Behaviour |
|---|---|
-o <FILE> |
Write result to a new file |
--overwrite |
Replace the input file in-place |
--stdout |
Print result to standard output |
encrypt
Encrypt scalar values inside a JSON or YAML file using Ansible Vault AES256.
rvault encrypt -i <INPUT> (-o <OUTPUT> | --overwrite | --stdout)
--password <PASSWORD>
[-k <KEY>]...
[--level <DEPTH>]
[--ansible]
Encrypt all values in a file:
Encrypt specific keys using dot-notation paths:
# single key
# multiple keys (repeat the flag or use comma-separation)
Encrypt by nesting depth with --level (cannot be combined with --key):
# encrypt all values at the top level (depth 1)
# encrypt all values two levels deep
Overwrite the file in-place:
Print to stdout (useful for piping):
decrypt
Decrypt some or all encrypted values in a partially-encrypted file.
rvault decrypt -i <INPUT> (-o <OUTPUT> | --overwrite | --stdout)
--password <PASSWORD>
[-k <KEY>]...
[--value-only]
[--interactive]
Decrypt all values:
Decrypt specific keys:
Value-only mode (--value-only / -v) — output only the selected key(s) as a minimal nested document (requires at least one --key or --interactive):
# prints just the nested sub-document for the selected keys
Interactive (fuzzy) mode — opens an interactive prompt to select which encrypted keys to decrypt:
# combine with --value-only to output only the selected values
edit
Decrypt a value, open it in $EDITOR, then re-encrypt and save.
rvault edit -i <INPUT> (-o <OUTPUT> | --overwrite | --stdout)
--password <PASSWORD>
[-k <KEY>]...
[-a | --interactive]
Edit a specific key:
Edit multiple keys:
Fuzzy-select which key to edit (default when no --key is given):
Edit all encrypted values without selection (-a):
clip
Fuzzy-search encrypted values and copy the decrypted result to the clipboard. The clipboard is automatically cleared after a timeout.
rvault clip -i <INPUT> --password <PASSWORD>
[--timeout <SECONDS>]
[--pfile <FILE>]
# default: clear clipboard after 30 seconds
# keep clipboard for 60 seconds
# never clear the clipboard automatically
File format
rvault works with plain JSON or YAML files. Encrypted values are stored inline as Ansible Vault strings:
# example.yaml — mixed plain/encrypted YAML
first:
z: last
a: first
m: middle
second:
a:
v: true # plain boolean
w: 14 # plain integer
x: "$ANSIBLE_VAULT;1.1;AES256\n..." # encrypted string
The original Rust type (bool, integer, float, string) is preserved across an encrypt→decrypt round-trip.
Docker
# decrypt a file
# encrypt a file
Build
# build binary
# run tests
# build docker image
Mac OS Builds
To do cargo install under Mac OS you need at first to install Rust.
That the linking of the final program works you need the Mac OS developer
tools too. You can install them with xcode-select --install.
Attention, after executing the xcode-select command a new window opens.
Sometimes this window is hidden in the stack of other open program windows.
Additional
- Password for
resources/tests/partial.yaml:aa - Password for
resources/tests/partial_encrypted_example.json:test999 - Password for
resources/tests/partial_encrypted_example.yaml:test999