titoshadow / ansible-vault
A PHP wrapper for the ansible-vault command.
1.0.1
2025-05-07 19:44 UTC
Requires
- php: ^8.3
- symfony/process: ^7.0
Requires (Dev)
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2025-05-07 20:01:25 UTC
README
This library provides a simple PHP wrapper for the ansible-vault
command, allowing to encrypt and decrypt content,
and manage vaults directly within PHP.
Requirements
- PHP 8.3 or later
- Ansible 2.10 or later
- Ansible Vault must be available in your system PATH
Installation
Ensure Ansible is installed and configured correctly before using this library.
You can install this library via Composer:
composer require titoshadow/ansible-vault
Usage
Include the library in your PHP code:
use Titoshadow\AnsibleVault\AnsibleVault; ... // Create an instance of the library $vault = new AnsibleVault('/path/to/vault-password-file');
Encrypt a String
$encryptedString = $vault->encryptString('Sensitive data');
Decrypt a String
$decryptedString = $vault->decryptString($encryptedString);
Encrypt a File
$vault->encrypt('/path/to/plain-text-file');
Decrypt a File
$vault->decrypt('/path/to/encrypted-file');
Create a Vault
$vault->create('/path/to/new-vault-file', 'Content of the vault');
Edit a Vault
$vault->edit('/path/to/vault-file');
Rekey a Vault
$vault->rekey('/path/to/vault-file', 'old-password', 'new-password');
Remove a Vault
$vault->remove('/path/to/vault-file');