Skip to content

Commit 9394b27

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 a specialized 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. Key Components 1. Core Adoption Role (`barbican_proteccio_adoption`) 2. User-Friendly Execution Script 3. Security-Hardened Configuration Adoption Phases 1. **Phase 1 (Preparation)**: Extract source configuration and validate environment 2. **Phase 2 (Base Deployment)**: Deploy RHOSO 18 with standard images 3. **Phase 3 (Database Adoption)**: Migrate Barbican database and execute HSM role 4. **Phase 4 (Proteccio Deployment)**: Deploy custom images and HSM configuration 5. **Phase 5 (Verification)**: Validate adoption success and API functionality Execution Approaches - **Primary**: `./run_proteccio_adoption.sh` (user-friendly with validation) - **Alternative**: Direct `ansible-playbook` execution (advanced users/troubleshooting) Fixes: OSPRH-18981 Signed-off-by: Mauricio Harley <[email protected]>
1 parent f64670e commit 9394b27

21 files changed

+1504
-0
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_proteccio_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/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 specifically for the barbican_proteccio_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+
# This file is generated automatically by the barbican_proteccio_adoption role
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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# Main playbook for Barbican adoption with Proteccio HSM integration
3+
# OpenStack 17.1 to RHOSO 18 adoption
4+
5+
- name: Barbican Adoption with Proteccio 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_proteccio_adoption
39+
40+
post_tasks:
41+
- name: Display completion summary
42+
ansible.builtin.debug:
43+
msg: |
44+
===============================================
45+
ADOPTION COMPLETED SUCCESSFULLY!
46+
===============================================
47+
48+
Barbican adoption with Proteccio HSM integration has been completed.
49+
50+
Key achievements:
51+
- Database adopted with {{ adopted_secrets_count | default('N/A') }} secrets
52+
- Proteccio custom images deployed
53+
- HSM configuration applied
54+
- API functionality verified
55+
56+
Check the generated summary file for detailed results.
57+
===============================================
58+
59+
handlers:
60+
- name: Clean up temporary files
61+
ansible.builtin.file:
62+
path: "{{ item }}"
63+
state: absent
64+
loop:
65+
- "{{ backup_dir }}/temp_*"
66+
listen: "cleanup"
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Barbican Proteccio Adoption Role
2+
3+
Ansible role for adopting Barbican service from OpenStack 17.1 to RHOSO 18 with Proteccio HSM integration.
4+
5+
## 🔗 **Relationship to Existing Barbican Adoption Role**
6+
7+
This repository contains **two distinct Barbican adoption roles**:
8+
9+
### 1. `barbican_adoption` (Standard)
10+
- **Purpose**: Standard Barbican adoption without HSM
11+
- **Backend**: Uses `simple_crypto` plugin only
12+
- **Use Case**: Standard OpenStack deployments
13+
- **Process**: Simple configuration adoption and service deployment
14+
15+
### 2. `barbican_proteccio_adoption` (HSM-Enabled) - **This Role**
16+
- **Purpose**: Barbican adoption with Proteccio HSM integration
17+
- **Backend**: Supports both `simple_crypto` and `pkcs11` (HSM) plugins
18+
- **Use Case**: High-security environments requiring HSM
19+
- **Process**: Complex multi-phase adoption with HSM configuration
20+
21+
**WARNING: Important**: These roles are **mutually exclusive**. Choose the appropriate role based on your source environment:
22+
- If your TripleO 17.1 has **standard Barbican** → use `barbican_adoption`
23+
- If your TripleO 17.1 has **Proteccio HSM integration** → use `barbican_proteccio_adoption`
24+
25+
## WARNING: **IMPORTANT: Customization Required**
26+
27+
**This role contains placeholder values that MUST be customized for your environment before use.**
28+
29+
### Required Customization Steps:
30+
31+
1. **Copy and customize the sample variables:**
32+
```bash
33+
cp vars/sample_environment.yml vars/my_environment.yml
34+
# Edit vars/my_environment.yml with your values
35+
```
36+
37+
2. **Generate your own KEK key:**
38+
```bash
39+
openssl rand -base64 32
40+
```
41+
42+
3. **Update the following in `vars/my_environment.yml`:**
43+
- `source_undercloud_host`: Your actual undercloud hostname
44+
- `source_controller_host`: Your actual controller hostname
45+
- `barbican_simple_crypto_kek`: Your generated 32-byte base64 key
46+
- `hsm_login_password`: Your HSM login password
47+
- `hsm_token_labels`: Your HSM token label
48+
- `proteccio_required_files`: List your actual certificate filenames
49+
- `work_dir` and `proteccio_files_dir`: Your actual directory paths
50+
51+
4. **Use your custom variables:**
52+
```bash
53+
ansible-playbook -i inventory.proteccio.yaml -e @vars/my_environment.yml playbooks/barbican_proteccio_adoption.yml
54+
```
55+
56+
## Key Features
57+
58+
- **Automatic RabbitMQ user management** to prevent service authentication failures
59+
- **Graceful HSM role dependency handling** with fallback mechanisms
60+
- **Database adoption with backup and verification** capabilities
61+
- **Custom Proteccio image deployment** and HSM configuration management
62+
- **Comprehensive relationship with standard adoption** - clearly separated workflows
63+
64+
## Documentation
65+
66+
For complete documentation, see the official adoption guide:
67+
68+
- **Procedure**: `docs_user/modules/proc_adopting-key-manager-service-with-proteccio-hsm.adoc`
69+
- **Concept**: `docs_user/modules/con_key-manager-service-adoption-approaches.adoc`
70+
- **Troubleshooting**: `docs_user/modules/ref_troubleshooting-key-manager-proteccio-adoption.adoc`
71+
72+
## Quick Start
73+
74+
**WARNING: DO NOT run without customization - it will fail with placeholder values!**
75+
76+
### **Recommended Approach: Use the Adoption Script**
77+
78+
```bash
79+
# 1. Navigate to the tests directory
80+
cd /path/to/your/dp-adopt/tests
81+
82+
# 2. Configure script environment
83+
cp config.env.sample config.env
84+
vim config.env # Update paths for your environment
85+
86+
# 3. Customize role variables
87+
cp roles/barbican_proteccio_adoption/vars/sample_environment.yml \
88+
roles/barbican_proteccio_adoption/vars/my_environment.yml
89+
vim roles/barbican_proteccio_adoption/vars/my_environment.yml # Update with your values
90+
91+
# 4. Execute the adoption
92+
./run_proteccio_adoption.sh
93+
```
94+
95+
### **Alternative: Direct Ansible Execution (Advanced Users)**
96+
97+
```bash
98+
# For advanced users or troubleshooting specific phases
99+
ansible-playbook -i inventory.proteccio.yaml \
100+
-e @roles/barbican_proteccio_adoption/vars/my_environment.yml \
101+
playbooks/barbican_proteccio_adoption.yml
102+
```
103+
104+
## Dependencies
105+
106+
### **MANDATORY Requirements**
107+
108+
- **`ansible-role-rhoso-proteccio-hsm` role**: **REQUIRED** - This role is absolutely mandatory for Proteccio HSM adoption. It MUST be executed either:
109+
- As part of this adoption process (automatic execution), OR
110+
- Before running this adoption process (manual execution)
111+
- **WITHOUT THIS ROLE, THE ADOPTION WILL FAIL**
112+
113+
- **Proteccio client files**: All certificate and key files must be present in the specified directory
114+
- **OpenStack 17.1 source environment** with **Proteccio HSM integration** already configured
115+
- **RHOSO 18 target cluster** with administrative access
116+
- **Kubernetes/OpenShift CLI access** with appropriate permissions
117+
118+
### **Critical HSM Role Information**
119+
120+
The `ansible-role-rhoso-proteccio-hsm` role is responsible for:
121+
- Creating essential Kubernetes secrets (`hsm-login`, `proteccio-data`)
122+
- Mounting Proteccio certificate files in the target environment
123+
- Configuring HSM authentication for Barbican services
124+
125+
**This role is NOT optional**. If you attempt to run the adoption without it:
126+
- The adoption process will fail with clear error messages
127+
- Barbican services will not be able to access the HSM
128+
- Your existing HSM-protected secrets will become inaccessible
129+
130+
## Troubleshooting
131+
132+
If Barbican services show CrashLoopBackOff after deployment, the role automatically:
133+
1. Extracts RabbitMQ credentials from transport URLs
134+
2. Creates missing RabbitMQ users
135+
3. Sets appropriate permissions
136+
4. The services should recover automatically
137+
138+
## Security Note
139+
140+
**Never commit files containing real credentials, passwords, or certificate data to version control.**
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# Default variables for OpenStack adoption
3+
4+
# Source environment connection details (CUSTOMIZE THESE)
5+
source_undercloud_host: "CHANGE_ME_UNDERCLOUD_HOSTNAME" # Change to your undercloud hostname
6+
source_controller_host: "CHANGE_ME_CONTROLLER_HOSTNAME.ctlplane" # Change to your controller hostname
7+
8+
# Target RHOSO environment
9+
target_namespace: "openstack"
10+
target_storage_class: "local-storage"
11+
12+
# Database configuration (GENERATE YOUR OWN KEK)
13+
barbican_simple_crypto_kek: "CHANGE_ME_GENERATE_32_BYTE_BASE64_KEY" # openssl rand -base64 32
14+
15+
# Proteccio HSM configuration (CUSTOMIZE THESE IMAGE URLS)
16+
proteccio_custom_images:
17+
barbican_api: "CHANGE_ME_YOUR_REGISTRY/barbican-api:CHANGE_ME_YOUR_TAG" # Replace with your Proteccio-enabled Barbican API image
18+
barbican_worker: "CHANGE_ME_YOUR_REGISTRY/barbican-worker:CHANGE_ME_YOUR_TAG" # Replace with your Proteccio-enabled Barbican Worker image
19+
20+
# HSM configuration (CUSTOMIZE THESE)
21+
hsm_login_password: "CHANGE_ME_YOUR_HSM_PASSWORD" # Replace with your HSM password
22+
hsm_token_labels: "CHANGE_ME_YOUR_HSM_TOKEN_LABEL" # Replace with your HSM token label
23+
hsm_mkek_label: "CHANGE_ME_YOUR_MKEK_LABEL" # Replace with your MKEK label
24+
hsm_hmac_label: "CHANGE_ME_YOUR_HMAC_LABEL" # Replace with your HMAC label
25+
26+
# Required Proteccio client files (list of filenames expected in proteccio_files_dir)
27+
# CUSTOMIZE THIS LIST with your actual certificate and key filenames
28+
proteccio_required_files:
29+
- "CHANGE_ME_YOUR_CLIENT_CERT_FILENAME.crt" # Your Proteccio client certificate
30+
- "CHANGE_ME_YOUR_CLIENT_KEY_FILENAME.key" # Your Proteccio client private key
31+
- "CHANGE_ME_YOUR_CONFIG_FILENAME.rc" # Your Proteccio configuration file
32+
- "CHANGE_ME_YOUR_HSM_CERT_FILENAME.crt" # Your HSM certificate
33+
34+
# Service replica counts
35+
barbican_api_replicas: 1
36+
barbican_worker_replicas: 1
37+
barbican_keystone_listener_replicas: 1
38+
39+
# Adoption settings
40+
backup_database: true
41+
verify_adoption: true
42+
start_with_simple_crypto: true
43+
handle_rabbitmq_users: true
44+
# NOTE: The ansible-role-rhoso-proteccio-hsm role is MANDATORY for Proteccio environments
45+
# It must be available and executable, either as part of this process or run beforehand
46+
require_hsm_role: true
47+
48+
# Verification settings (CUSTOMIZE THESE)
49+
# List of secret names to specifically verify during adoption
50+
# Leave empty to skip specific secret verification
51+
expected_secrets_to_verify: [] # Example: ["hsm-secret", "my-important-secret"]
52+
verify_any_secrets: true # If true, verify that ANY secrets were adopted (recommended)
53+
54+
# Timeouts (seconds)
55+
service_ready_timeout: 600
56+
database_import_timeout: 300
57+
58+
# Working directories (CUSTOMIZE THESE PATHS)
59+
work_dir: "{{ ansible_env.PWD | default('/tmp/adopt_proteccio') }}" # Current working directory or change as needed
60+
proteccio_base_dir: "{{ proteccio_base_dir | default('/home/' + ansible_user + '/adopt_proteccio') }}" # Base directory for all Proteccio files
61+
proteccio_files_dir: "{{ proteccio_files_dir | default(proteccio_base_dir + '/proteccio_files') }}" # Proteccio certificate files directory
62+
hsm_role_path: "{{ hsm_role_path | default(proteccio_base_dir + '/roles/ansible-role-rhoso-proteccio-hsm') }}" # HSM role path
63+
backup_dir: "{{ backup_dir | default(work_dir + '/backups') }}"
64+
65+
# TripleO configuration files (CUSTOMIZE THESE PATHS)
66+
tripleo_passwords_file: "CHANGE_ME_PATH_TO_OVERCLOUD_PASSWORDS_YAML" # Path to overcloud passwords file (usually /home/USER/overcloud-passwords.yaml)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
galaxy_info:
3+
author: Red Hat
4+
description: Automated Barbican adoption from OpenStack 17.1 to RHOSO 18 with Proteccio HSM
5+
company: Red Hat
6+
license: Apache-2.0
7+
min_ansible_version: "2.9"
8+
platforms:
9+
- name: EL
10+
versions:
11+
- all
12+
galaxy_tags:
13+
- openstack
14+
- adoption
15+
- barbican
16+
- hsm
17+
- proteccio
18+
19+
dependencies: []

0 commit comments

Comments
 (0)