Skip to content

Commit ce29245

Browse files
author
Mauricio Harley
committed
Add Barbican adoption framework for Proteccio HSM environments
Implement a comprehensive adoption framework for migrating Barbican service from OpenStack 17.1 to RHOSO 18 while preserving Proteccio Hardware Security Module (HSM) integration. This PR introduces extends the Barbican adoption role and supporting infrastructure for environments that use Proteccio HSM with Barbican key management service. The standard data-plane-adoption framework does not support HSM backends, making this specialized approach necessary to preserve HSM integration and access to existing secrets. Fixes: OSPRH-18981 Signed-off-by: Mauricio Harley <[email protected]>
1 parent f64670e commit ce29245

File tree

13 files changed

+714
-6
lines changed

13 files changed

+714
-6
lines changed

tests/config.env.sample

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Sample configuration file for run_proteccio_adoption.sh
2+
# Copy this file to config.env and customize for your environment
3+
4+
# Base directory for Proteccio adoption files
5+
# Default uses current user's home directory
6+
PROTECCIO_BASE_DIR="$HOME/adopt_proteccio"
7+
8+
# Path to the Proteccio HSM Ansible role
9+
PROTECCIO_ROLES_DIR="$PROTECCIO_BASE_DIR/roles/ansible-role-rhoso-proteccio-hsm"
10+
11+
# Directory containing Proteccio client certificates and configuration files
12+
PROTECCIO_FILES_DIR="$PROTECCIO_BASE_DIR/proteccio_files"
13+
14+
# Ansible inventory file for the adoption
15+
INVENTORY_FILE="inventory.proteccio.yaml"
16+
17+
# Ansible playbook file for the adoption
18+
PLAYBOOK_FILE="playbooks/barbican_hsm_adoption.yml"
19+
20+
# Expected user account (user that should run the script)
21+
EXPECTED_USER="stack"
22+
23+
# Additional Ansible variables (optional)
24+
# export ANSIBLE_HOST_KEY_CHECKING=False
25+
# export ANSIBLE_TIMEOUT=60

tests/hsm_vars/common.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# Common HSM adoption variables (vendor-agnostic)
3+
# All values should be overridden by user-specific configurations
4+
5+
enable_hsm_integration: true
6+
enable_phased_hsm_adoption: false
7+
8+
# Target environment configuration (user must override)
9+
target_kubeconfig_path: "{{ user_kubeconfig_path | default('/home/user/.kube/config') }}"
10+
oc_binary_path: "{{ user_oc_path | default('/usr/local/bin') }}"
11+
target_namespace: "{{ user_target_namespace | default('openstack') }}"
12+
13+
# Common HSM settings
14+
barbican_hsm_enabled: true
15+
barbican_default_secret_store: "{{ user_default_secret_store | default('pkcs11') }}"
16+
barbican_enabled_secret_stores: "{{ user_enabled_stores | default(['simple_crypto', 'pkcs11']) }}"
17+
18+
# Custom image settings (must be set by user)
19+
use_custom_barbican_images: "{{ user_enable_custom_images | default(true) }}"
20+
barbican_dest_image_registry: "{{ user_image_registry | default('CHANGE_ME_REGISTRY') }}"
21+
barbican_dest_image_namespace: "{{ user_image_namespace | default('CHANGE_ME_NAMESPACE') }}"
22+
barbican_dest_image_tag: "{{ user_image_tag | default('CHANGE_ME_TAG') }}"
23+
24+
# Adoption control
25+
create_adoption_summary: "{{ user_create_summary | default(true) }}"
26+
summary_output_path: "{{ user_summary_path | default('/tmp/barbican_hsm_adoption_summary.md') }}"
27+
28+
# Internal API network (user configurable)
29+
internalapi_prefix: "{{ user_internal_api_prefix | default('172.17.0') }}"

tests/hsm_vars/proteccio.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
# Proteccio-specific HSM configuration
3+
# All values should be overridden by user-specific configurations
4+
5+
hsm_vendor: "proteccio"
6+
7+
# Proteccio HSM connection settings (user must configure)
8+
proteccio_hsm_tokens: "{{ user_proteccio_tokens | default(['CHANGE_ME_TOKEN']) }}"
9+
proteccio_mkek_name: "{{ user_proteccio_mkek | default('CHANGE_ME_MKEK') }}"
10+
proteccio_hmac_name: "{{ user_proteccio_hmac | default('CHANGE_ME_HMAC') }}"
11+
proteccio_library_path: "{{ user_proteccio_lib_path | default('/opt/tw_proteccio/lib/libnethsm.so') }}"
12+
proteccio_login_password: "{{ user_proteccio_password | default('CHANGE_ME_PASSWORD') }}"
13+
14+
# Proteccio client configuration (user must provide)
15+
proteccio_client_iso: "{{ user_proteccio_iso | default('CHANGE_ME_ISO_FILENAME') }}"
16+
proteccio_config_file: "{{ user_proteccio_config | default('proteccio.rc') }}"
17+
18+
# Proteccio secrets in target environment (user configurable)
19+
proteccio_login_secret: "{{ user_proteccio_login_secret | default('hsm-login') }}"
20+
proteccio_client_data_secret: "{{ user_proteccio_data_secret | default('proteccio-data') }}"
21+
proteccio_client_data_path: "{{ user_proteccio_data_path | default('/etc/proteccio') }}"
22+
23+
# Proteccio custom images (user must configure)
24+
barbican_dest_image_namespace: "{{ user_image_namespace | default('CHANGE_ME_NAMESPACE') }}"
25+
barbican_dest_image_tag: "{{ user_image_tag | default('CHANGE_ME_TAG') }}"
26+
barbican_api_image_name: "{{ user_api_image_name | default('openstack-barbican-api') }}"
27+
barbican_worker_image_name: "{{ user_worker_image_name | default('openstack-barbican-worker') }}"
28+
29+
# File paths (user must override with actual paths)
30+
proteccio_certs_path: "{{ user_proteccio_certs_path | default('CHANGE_ME_CERTS_PATH') }}"
31+
proteccio_config_path: "{{ user_proteccio_config_path | default('CHANGE_ME_CONFIG_PATH') }}"
32+
proteccio_iso_path: "{{ user_proteccio_iso_path | default('CHANGE_ME_ISO_PATH') }}"
33+
34+
# Ansible role configuration (user configurable)
35+
proteccio_hsm_role_name: "{{ user_proteccio_role | default('ansible-role-rhoso-proteccio-hsm') }}"
36+
37+
# Replica configuration (user configurable)
38+
barbican_api_replicas: "{{ user_api_replicas | default(2) }}"
39+
barbican_worker_replicas: "{{ user_worker_replicas | default(2) }}"
40+
barbican_keystone_listener_replicas: "{{ user_keystone_replicas | default(2) }}"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
# User Configuration Template for HSM Adoption
3+
# Copy this file to user_config.yml and customize all values
4+
#
5+
# IMPORTANT: Replace ALL values marked with CHANGE_ME_*
6+
7+
# ============================================
8+
# ENVIRONMENT CONFIGURATION
9+
# ============================================
10+
user_kubeconfig_path: "CHANGE_ME_KUBECONFIG_PATH" # e.g., "/home/user/.kube/config"
11+
user_oc_path: "CHANGE_ME_OC_PATH" # e.g., "/usr/local/bin"
12+
user_target_namespace: "CHANGE_ME_NAMESPACE" # e.g., "openstack"
13+
user_internal_api_prefix: "CHANGE_ME_API_PREFIX" # e.g., "172.17.0"
14+
15+
# ============================================
16+
# CONTAINER REGISTRY CONFIGURATION
17+
# ============================================
18+
user_image_registry: "CHANGE_ME_REGISTRY" # e.g., "quay.io" or "registry.example.com"
19+
user_image_namespace: "CHANGE_ME_NAMESPACE" # e.g., "your_org/barbican"
20+
user_image_tag: "CHANGE_ME_TAG" # e.g., "latest-proteccio"
21+
user_api_image_name: "CHANGE_ME_API_IMAGE" # e.g., "openstack-barbican-api"
22+
user_worker_image_name: "CHANGE_ME_WORKER_IMAGE" # e.g., "openstack-barbican-worker"
23+
24+
# ============================================
25+
# PROTECCIO HSM CONFIGURATION
26+
# ============================================
27+
user_proteccio_tokens: "CHANGE_ME_TOKEN_LIST" # e.g., ["TOKEN1", "TOKEN2"]
28+
user_proteccio_mkek: "CHANGE_ME_MKEK_LABEL" # e.g., "my_mkek_label"
29+
user_proteccio_hmac: "CHANGE_ME_HMAC_LABEL" # e.g., "my_hmac_label"
30+
user_proteccio_password: "CHANGE_ME_HSM_PASSWORD" # Your HSM login password
31+
user_proteccio_lib_path: "CHANGE_ME_LIB_PATH" # e.g., "/opt/tw_proteccio/lib/libnethsm.so"
32+
33+
# ============================================
34+
# PROTECCIO FILE PATHS
35+
# ============================================
36+
user_proteccio_certs_path: "CHANGE_ME_CERTS_PATH" # e.g., "/opt/proteccio/certs"
37+
user_proteccio_config_path: "CHANGE_ME_CONFIG_PATH" # e.g., "/opt/proteccio"
38+
user_proteccio_iso_path: "CHANGE_ME_ISO_PATH" # e.g., "/opt/proteccio"
39+
user_proteccio_iso: "CHANGE_ME_ISO_FILENAME" # e.g., "Proteccio3.06.05.iso"
40+
user_proteccio_config: "CHANGE_ME_CONFIG_FILE" # e.g., "proteccio.rc"
41+
42+
# ============================================
43+
# KUBERNETES SECRETS
44+
# ============================================
45+
user_proteccio_login_secret: "CHANGE_ME_LOGIN_SECRET" # e.g., "hsm-login"
46+
user_proteccio_data_secret: "CHANGE_ME_DATA_SECRET" # e.g., "proteccio-data"
47+
user_proteccio_data_path: "CHANGE_ME_DATA_PATH" # e.g., "/etc/proteccio"
48+
49+
# ============================================
50+
# SERVICE CONFIGURATION
51+
# ============================================
52+
user_api_replicas: "CHANGE_ME_API_REPLICAS" # e.g., 2
53+
user_worker_replicas: "CHANGE_ME_WORKER_REPLICAS" # e.g., 2
54+
user_keystone_replicas: "CHANGE_ME_KS_REPLICAS" # e.g., 2
55+
user_default_secret_store: "CHANGE_ME_DEFAULT_STORE" # e.g., "pkcs11"
56+
user_enabled_stores: "CHANGE_ME_ENABLED_STORES" # e.g., ["simple_crypto", "pkcs11"]
57+
58+
# ============================================
59+
# ANSIBLE ROLE CONFIGURATION
60+
# ============================================
61+
user_proteccio_role: "CHANGE_ME_ROLE_NAME" # e.g., "ansible-role-rhoso-proteccio-hsm"
62+
63+
# ============================================
64+
# OUTPUT CONFIGURATION
65+
# ============================================
66+
user_create_summary: "CHANGE_ME_CREATE_SUMMARY" # e.g., true
67+
user_summary_path: "CHANGE_ME_SUMMARY_PATH" # e.g., "/tmp/adoption_summary.md"

tests/inventory.proteccio.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
# Inventory for OpenStack Proteccio Adoption Role
3+
# Use this inventory for HSM-enabled barbican_adoption role
4+
# For standard dp-adopt framework, use inventory.yaml instead
5+
6+
all:
7+
hosts:
8+
localhost:
9+
ansible_connection: local
10+
ansible_python_interpreter: "{{ ansible_playbook_python }}"
11+
12+
children:
13+
adoption:
14+
hosts:
15+
localhost:

tests/my_vars.yaml.sample

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Sample source environment connection variables
2+
# Configure these variables for HSM-enabled Barbican adoption
3+
# Copy this file to my_vars.yaml and customize for your environment
4+
5+
UC_HOST: "YOUR_UNDERCLOUD_HOSTNAME"
6+
CTRL_HOST: "YOUR_CONTROLLER_HOSTNAME.ctlplane"
7+
controller1_ssh: "sudo ssh -t YOUR_UNDERCLOUD_HOSTNAME 'sudo -u stack ssh -t tripleo-admin@YOUR_CONTROLLER_HOSTNAME.ctlplane bash -lc'"
8+
undercloud_ssh: "sudo ssh -t YOUR_UNDERCLOUD_HOSTNAME 'sudo -u stack bash -lc'"
9+
tripleo_passwords:
10+
default: "/path/to/your/overcloud-passwords.yaml"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
# Main playbook for Barbican adoption with HSM integration (vendor-agnostic)
3+
# OpenStack 17.1 to RHOSO 18 adoption
4+
5+
- name: Barbican Adoption with HSM Integration
6+
hosts: localhost
7+
connection: local
8+
gather_facts: true
9+
become: false
10+
11+
vars: {}
12+
# Override default variables here if needed
13+
# source_undercloud_host: "your-undercloud-host"
14+
# source_controller_host: "your-controller-host"
15+
# target_namespace: "openstack"
16+
# barbican_simple_crypto_kek: "your-custom-kek"
17+
18+
pre_tasks:
19+
- name: Verify environment prerequisites
20+
block:
21+
- name: Check if running as correct user
22+
ansible.builtin.fail:
23+
msg: "This playbook should be run as the stack user"
24+
when: ansible_user_id != "stack"
25+
26+
- name: Verify oc/oc access
27+
ansible.builtin.command: oc cluster-info
28+
register: cluster_check
29+
failed_when: cluster_check.rc != 0
30+
31+
- name: Check OpenShift/Kubernetes cluster access
32+
ansible.builtin.command: "oc get namespace {{ target_namespace | default('openstack') }}"
33+
register: namespace_check
34+
changed_when: false
35+
failed_when: namespace_check.rc != 0
36+
37+
roles:
38+
- role: barbican_adoption
39+
vars:
40+
enable_hsm_integration: true
41+
hsm_vendor: "{{ hsm_vendor | default('proteccio') }}"
42+
43+
post_tasks:
44+
- name: Display completion summary
45+
ansible.builtin.debug:
46+
msg: |
47+
===============================================
48+
ADOPTION COMPLETED SUCCESSFULLY!
49+
===============================================
50+
51+
Barbican adoption with HSM integration has been completed.
52+
53+
Key achievements:
54+
- Database adopted with {{ adopted_secrets_count | default('N/A') }} secrets
55+
- HSM-enabled custom images deployed
56+
- HSM configuration applied
57+
- API functionality verified
58+
59+
Check the generated summary file for detailed results.
60+
===============================================
61+
62+
handlers:
63+
- name: Clean up temporary files
64+
ansible.builtin.file:
65+
path: "{{ item }}"
66+
state: absent
67+
loop:
68+
- "{{ backup_dir }}/temp_*"
69+
listen: "cleanup"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
# Universal HSM Adoption Coordinator
3+
# Works with any scenario by loading vendor-specific variables
4+
5+
- name: HSM-Enabled Barbican Adoption
6+
hosts: localhost
7+
gather_facts: true
8+
9+
vars_files:
10+
- "../../hsm_vars/common.yml"
11+
- "../../hsm_vars/{{ hsm_vendor }}.yml"
12+
13+
pre_tasks:
14+
- name: Validate HSM vendor specified
15+
ansible.builtin.fail:
16+
msg: "HSM vendor must be specified via -e hsm_vendor=<vendor>"
17+
when: hsm_vendor is not defined
18+
19+
- name: Validate supported HSM vendor
20+
ansible.builtin.fail:
21+
msg: "Unsupported HSM vendor: {{ hsm_vendor }}. Supported: proteccio, luna, ncipher"
22+
when: hsm_vendor not in ['proteccio', 'luna', 'ncipher']
23+
24+
- name: Display HSM adoption configuration
25+
ansible.builtin.debug:
26+
msg: |
27+
==========================================
28+
HSM-ENABLED BARBICAN ADOPTION
29+
==========================================
30+
Vendor: {{ hsm_vendor }}
31+
Scenario: {{ scenario_name | default('default') }}
32+
Target Namespace: {{ target_namespace }}
33+
Custom Images: {{ use_custom_barbican_images }}
34+
==========================================
35+
36+
tasks:
37+
- name: Setup HSM infrastructure
38+
ansible.builtin.include_tasks: "setup_{{ hsm_vendor }}_hsm.yml"
39+
40+
- name: Execute HSM-aware Barbican adoption
41+
ansible.builtin.include_role:
42+
name: barbican_adoption
43+
vars:
44+
# Pass HSM variables to the role
45+
enable_hsm_integration: "{{ enable_hsm_integration }}"
46+
hsm_vendor_override: "{{ hsm_vendor }}"
47+
48+
post_tasks:
49+
- name: Generate HSM adoption summary
50+
ansible.builtin.template:
51+
src: "../../roles/barbican_adoption/templates/hsm_adoption_summary.md.j2"
52+
dest: "{{ summary_output_path }}"
53+
mode: "0644"
54+
when: create_adoption_summary | default(true)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
# Proteccio HSM Infrastructure Setup (Fully Parameterized)
3+
- name: Setup Proteccio HSM Infrastructure
4+
block:
5+
- name: Validate all required variables are set
6+
ansible.builtin.fail:
7+
msg: |
8+
Required variable {{ item }} contains placeholder value.
9+
Please set all variables in user_config.yml before running.
10+
when: vars[item] is match("CHANGE_ME_.*")
11+
loop:
12+
- proteccio_certs_path
13+
- proteccio_config_path
14+
- proteccio_iso_path
15+
- proteccio_client_iso
16+
- proteccio_login_password
17+
- barbican_dest_image_registry
18+
- barbican_dest_image_namespace
19+
- barbican_dest_image_tag
20+
21+
- name: Validate Proteccio prerequisites exist
22+
ansible.builtin.stat:
23+
path: "{{ proteccio_iso_path }}/{{ proteccio_client_iso }}"
24+
register: proteccio_iso_check
25+
26+
- name: Fail if Proteccio ISO not found
27+
ansible.builtin.fail:
28+
msg: |
29+
Proteccio client ISO not found: {{ proteccio_iso_path }}/{{ proteccio_client_iso }}
30+
Please verify the path in user_config.yml
31+
when: not proteccio_iso_check.stat.exists
32+
33+
- name: Create Proteccio-enabled Barbican images
34+
ansible.builtin.include_role:
35+
name: "{{ proteccio_hsm_role_name }}"
36+
tasks_from: create_image
37+
vars:
38+
proteccio_password: "{{ proteccio_login_password }}"
39+
kubeconfig_path: "{{ target_kubeconfig_path }}"
40+
oc_dir: "{{ oc_binary_path }}"
41+
proteccio_client_crt_src: "file://{{ proteccio_certs_path }}/client.crt"
42+
proteccio_client_key_src: "file://{{ proteccio_certs_path }}/client.key"
43+
proteccio_server_crt_src: ["file://{{ proteccio_certs_path }}/server.crt"]
44+
proteccio_conf_src: "file://{{ proteccio_config_path }}/{{ proteccio_config_file }}"
45+
proteccio_client_src: "file://{{ proteccio_iso_path }}/{{ proteccio_client_iso }}"
46+
barbican_dest_image_registry: "{{ barbican_dest_image_registry }}"
47+
barbican_dest_image_namespace: "{{ barbican_dest_image_namespace }}"
48+
barbican_dest_image_tag: "{{ barbican_dest_image_tag }}"
49+
barbican_dest_api_image_name: "{{ barbican_api_image_name }}"
50+
barbican_dest_worker_image_name: "{{ barbican_worker_image_name }}"
51+
52+
- name: Create HSM secrets in target environment
53+
ansible.builtin.include_role:
54+
name: "{{ proteccio_hsm_role_name }}"
55+
tasks_from: create_secrets
56+
vars:
57+
proteccio_password: "{{ proteccio_login_password }}"
58+
kubeconfig_path: "{{ target_kubeconfig_path }}"
59+
oc_dir: "{{ oc_binary_path }}"
60+
proteccio_client_crt_src: "file://{{ proteccio_certs_path }}/client.crt"
61+
proteccio_client_key_src: "file://{{ proteccio_certs_path }}/client.key"
62+
proteccio_server_crt_src: ["file://{{ proteccio_certs_path }}/server.crt"]
63+
proteccio_conf_src: "file://{{ proteccio_config_path }}/{{ proteccio_config_file }}"
64+
proteccio_data_secret: "{{ proteccio_client_data_secret }}"
65+
proteccio_data_secret_namespace: "{{ target_namespace }}"
66+
login_secret: "{{ proteccio_login_secret }}"
67+
68+
- name: Apply custom Barbican images to control plane
69+
ansible.builtin.shell: |
70+
export KUBECONFIG="{{ target_kubeconfig_path }}"
71+
oc apply -f - <<EOF
72+
apiVersion: core.openstack.org/v1beta1
73+
kind: OpenStackVersion
74+
metadata:
75+
name: openstack
76+
namespace: {{ target_namespace }}
77+
spec:
78+
customContainerImages:
79+
barbicanAPIImage: {{ barbican_dest_image_registry }}/{{ barbican_dest_image_namespace }}/{{ barbican_api_image_name }}:{{ barbican_dest_image_tag }}
80+
barbicanWorkerImage: {{ barbican_dest_image_registry }}/{{ barbican_dest_image_namespace }}/{{ barbican_worker_image_name }}:{{ barbican_dest_image_tag }}
81+
EOF

0 commit comments

Comments
 (0)