pilfer
Decrypt all ansible vault files in a project in-place recursively for viewing/editing, then re-encrypt them all at once when you're done.
Optionally decrypt/re-encrypt all inline !vault values in-place, or re-key an entire tree after a password exposure.
Output
Example session:
Plain-text transcript
$ pilfer open --include-encrypted-vars --quiet
🔓 Searching for and decrypting vault files...
ℹ️ Found 4 vault target(s) (3 whole-file, 1 with inline values)
✅ All vault files decrypted. Edit as needed, then run 'pilfer close' to re-encrypt.
$ pilfer close
🔒 Re-encrypting vault files...
ℹ️ Re-encrypting modified file: inventory/group_vars/all/secrets.yml
ℹ️ Re-encrypting modified inline value(s) in: inventory/group_vars/all/all.yml (1 changed)
✅ Vault files re-encrypted. 2 modified files have been updated.
Quick start
Requires Python 3.12+ and ansible-core 2.21+. pip install pilfer installs ansible-core.
pipx install pilfer
cd your-ansible-project
pilfer open
# edit or search plaintext
pilfer close
Unchanged files are restored to their original ciphertext automatically.
Add to ansible.cfg so you do not need -p FILE on every run:
[defaults]
vault_password_file = ~/.ansible-vault/.vault-file
Features
- Fail-safe and battle tested: power outages and fat-fingers won't lose data
- Recursive: finds whole-file vaults anywhere under the current directory
- Supports inline
!vaultvalues: decrypted in place inside normal YAML - Clean diffs: only modified files are re-encrypted
- Re-keying: re-encrypts all your vaults with a new password after a leak
- Native Ansible: uses Ansible's own code for operations - no surprises
- Better than native:
pilfer setinserts a key's secret into a vault file in one command - Keyring client: keep the vault password in the macOS Keychain or Linux Secret Service
- Extensible: works with any client script, e.g.
agewith a YubiKey or Secure Enclave plugin
Commands
| Command | Purpose | Example |
|---|---|---|
open |
Decrypt the vault files in this tree | pilfer open |
close |
Re-encrypt what open decrypted |
pilfer close |
status |
Show whether a session is open and which files hold plaintext | pilfer status |
find-keys |
List which vault files hold a key; never prints values | pilfer find-keys '*token*' |
get |
Print one value, for piping into a command | pilfer get db_password | psql ... |
set |
Add or replace one key in a closed vault file | pilfer set secrets.yml db_password |
update |
Replace an existing key in whichever file holds it | pilfer update db_password |
rekey |
Change the vault password across the tree | pilfer rekey --dry-run --new-vault-id prompt |
completion |
Print a bash or zsh completion script | pilfer completion zsh > ~/.zfunc/_pilfer |
agent-guide |
Print a SKILL.md for AI coding agents |
pilfer agent-guide |
Run pilfer COMMAND --help for options, examples and exit statuses. docs/commands.md covers output formats, JSON shapes and the reasoning behind the commands.
Inline values
Whole-file vaults open by default. Inline !vault values are opt-in:
pilfer open --include-encrypted-vars
Each value becomes one quoted line followed by a # pilfer:vault:N marker, for example db_password: "the-secret" # pilfer:vault:0. Do not remove the marker: close uses it to find and re-encrypt the value. Do not commit while markers are present, or the plaintext and the session metadata land in git. close needs no flag and re-encrypts everything the session opened.
See docs/inline.md for the supported forms, what close checks and the refusal messages.
Vault passwords
Pilfer loads passwords with Ansible's own code, in the order ansible-vault uses: vault_identity_list, --vault-id, -p, vault_password_file, then the -J prompt. With no source named, it falls back to a few plain password files such as ~/.ansible-vault/.vault-file. pilfer-vault-keyring-client is a client script that reads the password from the macOS Keychain or Linux Secret Service.
Security: because pilfer loads passwords as ansible-vault does, a vault_password_file script named by the project's ansible.cfg runs whenever a command needs a password, even with -p. In a repo you did not write, read ansible.cfg first or point ANSIBLE_CONFIG at a file you trust.
See docs/passwords.md for the full order, fallback paths and keyring setup.
Rotating the vault password
pilfer close never changes a password. pilfer rekey rotates every vault in the current directory and below:
pilfer rekey --old-vault-password-file OLD --new-vault-password-file NEW --dry-run
pilfer rekey --old-vault-password-file OLD --new-vault-password-file NEW
pilfer rekey --old-vault-password-file OLD --new-vault-password-file NEW --rotate-password-file
The first checks that everything decrypts and prints the plan. The second asks you to type REKEY. The third also keeps the old password in <file>_old and installs the new one at the old path. After a failure, run the same command again to resume. See docs/rekey.md.
Safety
Pilfer fails closed: if it cannot prove a secret is safely re-encrypted or intentionally removed, it keeps the session and the .vault/ backups and exits non-zero. It does not invent fixes for ambiguous edits.
What to know:
- Never commit while a session is open.
closeis progressive: files that succeed are encrypted and dropped from the session, and failures stay plaintext until you fix them. Check its exit status.- A session belongs to the directory where
openran.pilfer statusreports sessions above and below the current directory. - Deleting or emptying an opened file needs an explicit choice (
pilfer close --confirm-delete, or put the content back).
More in docs/safety.md.
Gitignore
vaultedFileList.json
.vault/
**/*.pilfer-open
# Lock file that exists while pilfer works on a vault. Left behind only if pilfer is killed.
**/*.pilfer-lock
# Temp a killed pilfer can leave beside a file. The next open, close or rekey deletes it.
**/.pilfer-rekey-*
# --rotate-password-file leaves the old password here. Add `<your password file>_old`
# if your password file is inside the project.
.vault_password_old
vault_password_file_old
# `pilfer open` puts plaintext at the real path, so an editor's swap, backup and
# undo files beside it hold secrets and outlive `pilfer close`.
*~
.*.sw?
\#*\#
.*.un~
These patterns cover Vim and Emacs defaults. Check where your own editor writes backups and undo history; a central undo directory is outside the project and is not covered.
Pre-commit hook
A hook that compares content refuses a commit that turns a vault file into plaintext, and one that carries # pilfer:vault: markers. See docs/safety.md for the script.
Recovery
If close refuses, fix what it reports and run pilfer close again. If the session list or the .vault/ backups are lost, docs/safety.md has the steps for each case.
For AI agents
pilfer agent-guide prints a SKILL.md that tells a coding agent to find and change secrets with find-keys, update and set without printing values. Install it where your agent reads skills:
mkdir -p ~/.agents/skills/pilfer && pilfer agent-guide > ~/.agents/skills/pilfer/SKILL.md
Claude Code reads ~/.claude/skills/pilfer/SKILL.md. Run it again after upgrading pilfer. See docs/commands.md for the rest.
License
GPLv3+. See PILFER_LICENSE.txt.
Credits
Borrows heavily from the excellent, but no longer supported Ansible Toolkit.
Maintainers: development setup, releases, and CI details in .github/workflows/README.md.
Metadata
Release files for pilfer 3.3.0
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 | Actions |
|---|---|---|---|---|
| pilfer-3.3.0.tar.gz | 182.5 kB | With provenance | Details for pilfer-3.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pilfer-3.3.0-py3-none-any.whl | Python 3 | none | any | Details for pilfer-3.3.0-py3-none-any.whl |
Total release size: 297.0 kB
Release files / pilfer-3.3.0.tar.gz
| Download URL | pilfer-3.3.0.tar.gz |
|---|---|
| Size | 182.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c77ecd4592361e019367c31f1cef75e03deef914fc0a79cde8fc58ccff7f46ee
|
|
BLAKE2b-256 checksum How to use checksums |
21e75d391839f50f7abea7003b6b0fe35d859337d92b77760be970f82a813da8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 1, 2026.
Transparency logRelease files / pilfer-3.3.0-py3-none-any.whl
| Download URL | pilfer-3.3.0-py3-none-any.whl |
|---|---|
| Size | 114.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a29b9dbc6ba155a485cc17bf53651311c6e95a6cda484574bd75299aa7672c9c
|
|
BLAKE2b-256 checksum How to use checksums |
9af6f0f6936deaba5ba0e50221e1b52b0ed10f0f05662490e5678a3a074739f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 1, 2026.
Transparency logSecurity for pilfer 3.3.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pilfer-3.3.0.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 Dec 1, 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.