IT automation and orchestratio...
Ansible

Ansible configuration

5min

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 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 SSH and signing data.

Use Futurex PKCS #11 with Ansible - SSH example

1

Run the following commands to create an Ansible project working directory and switch to it:

Shell

2

Run the following command to create an inventory file:

Shell


The following shows an example inventory file using localhost:

Shell

3

Run the following command to create a playbook.yml file:

Shell


The following shows an example Ansible playbook file for testing SSH referencing the private key created in the previous section (ansible_rsa_privatekey):

Shell

  • Replace pkcs11_module with the location of the Futurex PKCS #11 library on your system.
  • Replace pkcs11_pin with the password you configured for the identity created for this integration.
  • Replace pkcs11_key_id with the label of the key you set when creating the key pair via PKCS11-tool.
4

To execute the playbook and reference the private key stored on the HSM during the SSH connection, run the following command, setting the username, inventory, and playbook file information according to your setup:

Shell

5

When prompted for the BECOME password In Ansible, use the become directive to escalate privileges when running tasks, similar to using sudo in the command line. The become_password is the user password specified in become_user (which defaults to root if not specified).

6

When prompted, enter the password of the user you are connecting to the machine with through SSH.

After entering the password, the process completes. If successful, you see a response similar to the following:

Shell

7

You can verify the successful pull of the private key within the FXPKCS11 log file or the log output shown in the command response.

Use Futurex PKCS #11 with Ansible - Encrypting and signing data example

1

Run the following commands to create an Ansible project working directory and switch to it:

Shell

2

Run the following command to create an inventory file:

Shell


The following example shows an inventory file using localhost:

Shell

3

Run the following command to create a playbook.yml file:

Shell


The following example shows an Ansible playbook file you can copy and use for encrypting data and signing data referencing the private key created in the previous section (ansible_rsa_privatekey):

  • Replace pkcs11_module with the location of the Futurex PKCS #11 library on your system.
  • Replace pkcs11_pin with the password you configured for the identity created for this integration.
  • Replace pkcs11_key_id with the label of the key you set when creating the key pair via PKCS11-tool.
Shell

4

To execute the playbook and reference the private key stored on the HSM during the SSH connection, run the following command, setting the username, inventory, and playbook file information according to your setup:

Shell

5

When prompted for the BECOME password In Ansible, use the become directive to escalate privileges when running tasks, similar to using sudo in the command line. The become_password is the password for the user specified in become_user (which defaults to root if not specified).

If successful, you should see a response similar to the following:

Shell

6

You can verify the signing and encryption operations within the FXPKCS11 log file or by checking the contents of the output file.