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 CryptoHub

Perform the following tasks to create a key pair:

1 | 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.

2 | Create a key pair on the CryptoHub 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. Refer to 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. The Ansible Vault uses this password 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 organization best practices.

This file is placed in the /tmp/ directory on the Linux machine for the encrypt and decrypt examples in this section.

Encrypt example

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

This example performs the following actions:

  1. Retrieves the key from the .
  2. Stores the key in a temporary file.
  3. Encrypts 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 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 (such as decrypt.yml) and modify it as needed.

This example performs the following actions:

  1. Retrieves the key from the .
  2. Stores the key in a temporary file.
  3. Encrypts 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 environment, use the following shell command to run the playbook:

Shell