Skip to content

PHP library to wrap ansible-vault command functionality

License

Notifications You must be signed in to change notification settings

titoshadow/ansible-vault

Repository files navigation

Ansible Vault PHP Wrapper

License: MIT Tests Coverage

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');

About

PHP library to wrap ansible-vault command functionality

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages