Download the PHP package titoshadow/ansible-vault without Composer
On this page you can find all versions of the php package titoshadow/ansible-vault. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download titoshadow/ansible-vault
More information about titoshadow/ansible-vault
Files in titoshadow/ansible-vault
Package ansible-vault
Short Description A PHP wrapper for the ansible-vault command.
License MIT
Informations about the package ansible-vault
Ansible Vault PHP Wrapper
A pragmatic, secure wrapper around ansible-vault
for encrypting/decrypting strings and files, editing vaults, and re-keying from PHP. Tailored for host-centric workflows like storing SSH passwords that Ansible uses to connect to remote hosts.
Requirements
- PHP 8.3 or later
- Ansible 2.10+ (
ansible-vault
available on the system)
Binary resolution and availability check
The wrapper locates ansible-vault
and validates availability with --version
.
Resolution order:
1) Constructor argument binary
2) Environment variable ANSIBLE_VAULT_BIN
3) Fallback to ansible-vault
in PATH
Installation
Ensure Ansible is installed and configured correctly before using this library.
You can install this library via Composer:
Usage
Include the library in your PHP code:
Security model and password handling
- Avoid plaintext passwords on the command line. This wrapper:
- Writes provided password strings to secure temp files (0600 on POSIX) and passes
--vault-password-file
. - Supports user-provided password file paths as-is.
- Writes provided password strings to secure temp files (0600 on POSIX) and passes
- Errors scrub secrets in both
--flag value
and--flag=value
forms (covers--vault-password
,--vault-password-file
,--password
,-p
, etc.).
Command execution settings
All commands run via a lightweight executor that supports:
- Default timeout (60s) and default working directory (null)
- Per-call override for timeout and cwd (used internally)
- TTY for interactive edit sessions
Configure defaults when needed:
Core methods
Encrypt a String (stdin-name control):
Decrypt a String
Encrypt a File
Decrypt a File
Create a Vault
Edit a Vault
Rekey a Vault
Remove a Vault
Host-centric SSH helpers
Encrypt an SSH password to the conventional variable ansible_ssh_pass
(in-memory):
Encrypt and write the SSH secret to a file (directories are created if missing):
Exceptions and error handling
On failures, a sanitized exception is thrown:
- VaultCliUsageException — typically exit code 2 (CLI misuse, invalid flags)
- VaultAuthException — typically exit code 4 (authentication/decryption issues)
- VaultExecutionException — default/fallback with masked secrets