Ansible Vault configuration
This section details the steps to configure the Ansible instance to integrate with the PKCS #11 library.
Perform the following tasks to create a key pair:
In a terminal, run the following commands to set the required FXPKCS11 environment variables:
Be sure to modify the file path to match the location of libfxpkcs11.so and fxpkcs11.cfg on your system.
In a terminal, run the following command to create a new ECC key pair on the by using pkcs11-tool:
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 .
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.
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.
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:
- Retrieves the key from the .
- Stores the key in a temporary file.
- Encrypts the temporary file with Ansible Vault.
- Uses the encrypted temporary key file to encrypt the target file.
- Cleans the encrypted temporary key file from the system.
After you modify the playbook file according to your environment, use the following shell command to run the playbook:
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:
- Retrieves the key from the .
- Stores the key in a temporary file.
- Encrypts the temporary file with Ansible Vault.
- Uses the encrypted temporary key file to decrypt the target file.
- Cleans the encrypted temporary key file from the system.
After you modify the playbook file according to your environment, use the following shell command to run the playbook: