IT automation and orchestratio...
Ansible Vault

Ansible Vault configuration

9min

This section details the steps to configure the Ansible instance to integrate with the PKCS #11 library.

Create a key pair on the Vectera Plus

Perform the following two tasks to create a key pair:

Set Futurex PKCS #11 environment variables

1

In a terminal, run the following commands to set the required FXPKCS11 environment variables:

Shell


Be sure to modify the file path to match the location of libfxpkcs11.so and fxpkcs11.cfg on your system.

Create a key pair on the Vectera Plus by using pkcs11-tool

1

In a terminal, run the following command to create a new ECC key pair on the by using pkcs11-tool:

Shell


When prompted for the user PIN, enter the password of the identity configured in the fxpkcs11.cfg file.

If successful, the command output lists the keys that pkcs11-tool created on the .

Ansible Vault playbooks

In Ansible, playbooks perform automated tasks. You can reference the PKCS #11 library when performing these tasks inside the playbook file to perform various functions, including encrypting and decrypting files.

Prerequisites

You must create a file for the Vault Password (such as vault_password_file.txt) and place it in the appropriate folder. This is the password that Ansible Vault uses to encrypt the HSM key and the file to be encrypted with the HSM key.

You must adjust the security of this file based on your organizations best practices.

For the following examples, this file is placed in the /tmp/ directory on the Linux machine.

Encrypt example

You must copy and paste the contents of this example into a file with the .yml extension and modify as needed. (such as, encrypt.yml)

The following example, performs the follwing actions

  1. Retrieves the key from the HSM.
  2. Stores the key in a temporary file.
  3. Encryptes the temporary file with Ansible Vault.
  4. Uses the encrypted temporary key file to encrypt the target file.
  5. Cleans the encrypted temporary key file from the system.
YAML


After you modify the playbook file according to your own environment, use the following shell command to run the playbook:

Shell


Decrypt example

You must copy and paste the contents of this example into a file with the .yml extension and modify as needed. (such as, decrypt.yml)

The following example, performs the follwing actions

  1. Retrieves the key from the HSM.
  2. Stores the key in a temporary file.
  3. Encryptes the temporary file with Ansible Vault.
  4. Uses the encrypted temporary key file to decrypt the target file.
  5. Cleans the encrypted temporary key file from the system.
YAML


After you modify the playbook file according to your own environment, use the following shell command to run the playbook:

Shell