Skip to content

Commit 3b6bfc9

Browse files
author
Mauricio Harley
committed
Add configuration and Ansible role for Barbican adoption with Proteccio HSM
These artifacts will be used for Proteccio HSM adoption. Implements: OSPRH-18874 Signed-off-by: Mauricio Harley <[email protected]>
1 parent c04a711 commit 3b6bfc9

18 files changed

+1045
-4
lines changed

deploy-osp-adoption.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,13 @@
105105
- name: Deploy source osp environment
106106
ansible.builtin.import_role:
107107
name: "adoption_osp_deploy"
108+
109+
- name: Run Barbican adoption when enabled
110+
when:
111+
- cifmw_barbican_adoption_enable | default(false) | bool
112+
- cifmw_barbican_adoption_hsm_enabled | default(false) | bool
113+
block:
114+
- name: Execute Barbican adoption with HSM support
115+
ansible.builtin.include: "playbooks/adoption/barbican-proteccio.yml"
116+
vars:
117+
osp_17_controller_host: "{{ groups['osp-controllers'][0] | default('') }}"

hooks/playbooks/barbican-enable-proteccio.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
tasks_from: create_secrets
3434
vars:
3535
proteccio_conf_src: "{{ cifmw_hsm_proteccio_conf_src }}"
36-
proteccio_client_crt_src: "{{ cifmw_hsm_proteccio_client_crt_src }}"
37-
proteccio_client_key_src: "{{ cifmw_hsm_proteccio_client_key_src }}"
38-
proteccio_server_crt_src: "{{ cifmw_hsm_proteccio_server_crt_src }}"
36+
proteccio_crt_src: "{{ cifmw_hsm_proteccio_crt_src }}"
3937
proteccio_password: "{{ cifmw_hsm_password }}"
4038
kubeconfig_path: "{{ cifmw_openshift_kubeconfig }}"
4139
oc_dir: "{{ cifmw_path }}"
@@ -44,16 +42,34 @@
4442
login_secret: "{{ cifmw_hsm_login_secret | default('barbican-proteccio-login', true) }}"
4543
login_secret_field: "{{ cifmw_hsm_login_secret_field | default('PKCS11Pin') }}"
4644

45+
- name: Handle adoption-specific HSM configuration
46+
when: cifmw_adoption_enable | default(false) | bool
47+
block:
48+
- name: Create adoption-specific proteccio configuration patch
49+
ansible.builtin.include_role:
50+
name: rhoso_proteccio_hsm
51+
tasks_from: create_adoption_patch
52+
vars:
53+
source_barbican_namespace: "{{ cifmw_adoption_source_namespace | default('openstack') }}"
54+
target_barbican_namespace: "{{ cifmw_adoption_target_namespace | default('openstack') }}"
55+
preserve_existing_secrets: "{{ cifmw_hsm_preserve_secrets | default(true) }}"
56+
4757
- name: Create kustomization to update Barbican to use proteccio
4858
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4959
tasks:
5060
- name: Create file to customize barbican resource deployed in the control plane
5161
vars:
5262
client_data_secret: "{{ cifmw_hsm_proteccio_client_data_secret | default('barbican-proteccio-client-data', true) }}"
5363
login_secret: "{{ cifmw_hsm_login_secret | default('barbican-proteccio-login', true) }}"
64+
kustomization_file: >-
65+
{%- if cifmw_adoption_enable | default(false) | bool -%}
66+
93-barbican-proteccio-adoption.yaml
67+
{%- else -%}
68+
93-barbican-proteccio.yaml
69+
{%- endif -%}
5470
ansible.builtin.copy:
5571
mode: '0644'
56-
dest: "{{ cifmw_basedir }}/artifacts/manifests/kustomizations/controlplane/93-barbican-proteccio.yaml"
72+
dest: "{{ cifmw_basedir }}/artifacts/manifests/kustomizations/controlplane/{{ kustomization_file }}"
5773
content: |-
5874
apiVersion: kustomize.config.k8s.io/v1beta1
5975
kind: Kustomization
@@ -94,3 +110,14 @@
94110
key_wrap_generate_iv = true
95111
always_set_cka_sensitive = true
96112
os_locking_ok = false
113+
{%- if cifmw_adoption_enable | default(false) | bool %}
114+
- op: add
115+
path: /spec/barbican/template/databaseInstance
116+
value: openstack
117+
- op: add
118+
path: /spec/barbican/template/secret
119+
value: osp-secret
120+
- op: add
121+
path: /spec/barbican/template/preserveJobs
122+
value: {{ cifmw_adoption_preserve_jobs | default(false) }}
123+
{%- endif %}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: "Barbican adoption for Proteccio HSM environments"
18+
hosts: "{{ cifmw_target_host | default('localhost') }}"
19+
gather_facts: true
20+
vars:
21+
# Enable adoption mode
22+
cifmw_adoption_enable: true
23+
24+
# Barbican adoption specific configuration
25+
cifmw_barbican_adoption_hsm_enabled: true
26+
cifmw_barbican_adoption_hsm_type: "proteccio"
27+
28+
# Source environment configuration (to be overridden)
29+
cifmw_barbican_adoption_source_db_host: "{{ osp_17_controller_host | default('') }}"
30+
cifmw_barbican_adoption_source_db_password: "{{ barbican_db_password | default('') }}"
31+
32+
# HSM configuration (to be overridden)
33+
cifmw_barbican_adoption_proteccio_partition: "{{ hsm_partition | default('') }}"
34+
cifmw_barbican_adoption_proteccio_mkek_label: "{{ hsm_mkek_label | default('') }}"
35+
cifmw_barbican_adoption_proteccio_hmac_label: "{{ hsm_hmac_label | default('') }}"
36+
37+
tasks:
38+
- name: Validate required variables for Proteccio adoption
39+
ansible.builtin.assert:
40+
that:
41+
- osp_17_controller_host is defined and osp_17_controller_host != ""
42+
- barbican_db_password is defined and barbican_db_password != ""
43+
- hsm_partition is defined and hsm_partition != ""
44+
- hsm_mkek_label is defined and hsm_mkek_label != ""
45+
- hsm_hmac_label is defined and hsm_hmac_label != ""
46+
fail_msg: "Required variables for Barbican Proteccio adoption are not properly configured"
47+
48+
- name: Run Barbican adoption with Proteccio HSM support
49+
ansible.builtin.include_role:
50+
name: barbican_adoption
51+
52+
- name: Enable Proteccio HSM for adopted Barbican
53+
ansible.builtin.include_role:
54+
name: run_hook
55+
vars:
56+
cifmw_run_hook_name: barbican-enable-proteccio
57+
58+
- name: Verify Barbican Proteccio adoption
59+
ansible.builtin.debug:
60+
msg: |
61+
Barbican adoption with Proteccio HSM support completed successfully.
62+
63+
Next steps:
64+
1. Verify Barbican API is accessible
65+
2. Test HSM connectivity
66+
3. Validate existing secrets are accessible
67+
4. Run smoke tests
68+
69+
Note: This playbook works with the uni07eta adoption scenario which
70+
includes Proteccio HSM support configuration.

roles/barbican_adoption/README.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# barbican_adoption
2+
3+
Role to support Barbican service adoption from OpenStack 17.1 to RHOSO 18 while preserving Hardware Security Module (HSM) integration, specifically designed for Proteccio HSM environments.
4+
5+
## Overview
6+
7+
This role implements a comprehensive adoption framework that:
8+
- Migrates Barbican database from source OSP 17.1 environment
9+
- Preserves HSM configuration and connectivity
10+
- Deploys Barbican in target RHOSO 18 environment
11+
- Validates successful adoption and HSM integration
12+
13+
## Features
14+
15+
- **Database Migration**: Automated backup and migration of Barbican database
16+
- **HSM Preservation**: Maintains Proteccio HSM configuration and secrets
17+
- **Service Migration**: Orchestrated shutdown of source services and deployment in target
18+
- **Validation**: Comprehensive verification of adoption success
19+
- **Rollback Support**: Backup creation for potential rollback scenarios
20+
21+
## Prerequisites
22+
23+
1. Access to source OSP 17.1 environment with Barbican + Proteccio HSM
24+
2. Target RHOSO 18 environment with OpenShift cluster
25+
3. Proteccio HSM certificates and configuration files
26+
4. Database access credentials for source environment
27+
28+
## Variables
29+
30+
### Required Variables
31+
32+
- `cifmw_barbican_adoption_source_db_host`: Source database hostname/IP
33+
- `cifmw_barbican_adoption_source_db_password`: Source database password
34+
- `cifmw_openshift_kubeconfig`: Path to OpenShift kubeconfig file
35+
36+
### HSM Configuration (when HSM enabled)
37+
38+
- `cifmw_barbican_adoption_proteccio_partition`: HSM partition/token name
39+
- `cifmw_barbican_adoption_proteccio_mkek_label`: Master key encryption key label
40+
- `cifmw_barbican_adoption_proteccio_hmac_label`: HMAC key label
41+
42+
### Optional Variables
43+
44+
- `cifmw_barbican_adoption_hsm_enabled`: Enable HSM support (default: false)
45+
- `cifmw_barbican_adoption_backup_enabled`: Create database backup (default: true)
46+
- `cifmw_barbican_adoption_preserve_jobs`: Preserve migration jobs (default: false)
47+
- `cifmw_barbican_adoption_debug`: Enable debug logging (default: false)
48+
49+
See `defaults/main.yml` for complete variable list.
50+
51+
## Usage
52+
53+
### Basic Adoption (No HSM)
54+
55+
```yaml
56+
- name: Adopt Barbican service
57+
ansible.builtin.include_role:
58+
name: barbican_adoption
59+
vars:
60+
cifmw_barbican_adoption_source_db_host: "192.168.1.100"
61+
cifmw_barbican_adoption_source_db_password: "secret123"
62+
```
63+
64+
### Proteccio HSM Adoption
65+
66+
```yaml
67+
- name: Adopt Barbican with Proteccio HSM
68+
ansible.builtin.include_role:
69+
name: barbican_adoption
70+
vars:
71+
cifmw_barbican_adoption_source_db_host: "192.168.1.100"
72+
cifmw_barbican_adoption_source_db_password: "secret123"
73+
cifmw_barbican_adoption_hsm_enabled: true
74+
cifmw_barbican_adoption_hsm_type: "proteccio"
75+
cifmw_barbican_adoption_proteccio_partition: "barbican_partition"
76+
cifmw_barbican_adoption_proteccio_mkek_label: "mkek_2024"
77+
cifmw_barbican_adoption_proteccio_hmac_label: "hmac_2024"
78+
```
79+
80+
### Using with Adoption Playbook
81+
82+
```bash
83+
ansible-playbook playbooks/adoption/barbican-proteccio.yml \
84+
-e osp_17_controller_host=192.168.1.100 \
85+
-e barbican_db_password=secret123 \
86+
-e hsm_partition=barbican_partition \
87+
-e hsm_mkek_label=mkek_2024 \
88+
-e hsm_hmac_label=hmac_2024
89+
```
90+
91+
## Integration with CI Framework
92+
93+
This role integrates with the existing ci-framework adoption infrastructure:
94+
95+
1. **Hooks Integration**: Works with `barbican-enable-proteccio.yml` hook
96+
2. **Adoption Framework**: Leverages existing `adoption_osp_deploy` role
97+
3. **Kustomization**: Creates appropriate Kubernetes manifests
98+
4. **Scenarios**: Can be used with adoption scenarios
99+
100+
## Architecture
101+
102+
The adoption process follows these phases:
103+
104+
1. **Validation**: Verify prerequisites and connectivity
105+
2. **Backup**: Create database and configuration backups
106+
3. **Migration**: Stop source services and migrate database
107+
4. **HSM Configuration**: Preserve and configure HSM integration
108+
5. **Deployment**: Deploy Barbican in target environment
109+
6. **Verification**: Validate adoption success
110+
7. **Cleanup**: Remove temporary files and old backups
111+
112+
## Error Handling
113+
114+
- Database migration failures trigger automatic rollback
115+
- HSM connectivity issues are validated before deployment
116+
- Comprehensive logging for troubleshooting
117+
- Backup creation ensures data protection
118+
119+
## Limitations
120+
121+
- Currently supports Proteccio HSM only (Luna HSM can be added)
122+
- Requires manual network connectivity between environments
123+
- Database migration requires temporary downtime
124+
125+
## Examples
126+
127+
See `playbooks/adoption/barbican-proteccio.yml` and `scenarios/adoption/uni07eta.yml` for complete usage examples.
128+
129+
## Testing
130+
131+
The role can be tested using the adoption scenario:
132+
133+
```bash
134+
ansible-playbook deploy-osp-adoption.yml \
135+
-e @scenarios/adoption/uni07eta.yml \
136+
-e osp_17_controller_host=192.168.1.100
137+
```
138+
139+
## Contributing
140+
141+
When extending this role:
142+
1. Follow existing variable naming conventions (`cifmw_barbican_adoption_*`)
143+
2. Add appropriate validation in `validate_prerequisites.yml`
144+
3. Update documentation and examples
145+
4. Test with both HSM and non-HSM scenarios
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
# All variables intended for modification should be placed in this file.
18+
# All variables within this role should have a prefix of "cifmw_barbican_adoption"
19+
20+
# General adoption configuration
21+
cifmw_barbican_adoption_source_namespace: "openstack"
22+
cifmw_barbican_adoption_target_namespace: "openstack"
23+
cifmw_barbican_adoption_preserve_jobs: false
24+
cifmw_barbican_adoption_db_migration_timeout: 3600
25+
cifmw_barbican_adoption_validation_timeout: 1800
26+
27+
# Database configuration
28+
cifmw_barbican_adoption_source_db_host: ""
29+
cifmw_barbican_adoption_source_db_port: 3306
30+
cifmw_barbican_adoption_source_db_name: "barbican"
31+
cifmw_barbican_adoption_source_db_user: "barbican"
32+
cifmw_barbican_adoption_source_db_password: ""
33+
34+
# HSM configuration
35+
cifmw_barbican_adoption_hsm_enabled: false
36+
cifmw_barbican_adoption_hsm_type: "proteccio" # or "luna"
37+
cifmw_barbican_adoption_preserve_hsm_config: true
38+
39+
# Proteccio HSM specific configuration
40+
cifmw_barbican_adoption_proteccio_client_data_secret: "barbican-proteccio-client-data"
41+
cifmw_barbican_adoption_proteccio_login_secret: "barbican-proteccio-login"
42+
cifmw_barbican_adoption_proteccio_login_secret_field: "PKCS11Pin"
43+
cifmw_barbican_adoption_proteccio_library_path: "/usr/lib64/libnethsm.so"
44+
cifmw_barbican_adoption_proteccio_partition: ""
45+
cifmw_barbican_adoption_proteccio_mkek_label: ""
46+
cifmw_barbican_adoption_proteccio_hmac_label: ""
47+
cifmw_barbican_adoption_proteccio_key_wrap_mechanism: "CKM_AES_KEY_WRAP"
48+
49+
# Service configuration
50+
cifmw_barbican_adoption_service_config_backup: true
51+
cifmw_barbican_adoption_service_config_restore: true
52+
cifmw_barbican_adoption_verify_connectivity: true
53+
54+
# Debug and logging
55+
cifmw_barbican_adoption_debug: false
56+
cifmw_barbican_adoption_log_level: "INFO"
57+
58+
# Backup and rollback configuration
59+
cifmw_barbican_adoption_backup_enabled: true
60+
cifmw_barbican_adoption_backup_retention_days: 30
61+
cifmw_barbican_adoption_rollback_enabled: true
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
galaxy_info:
18+
role_name: barbican_adoption
19+
namespace: cifmw
20+
author: CI Framework
21+
description: |
22+
Role to support Barbican adoption from OSP 17.1 to RHOSO 18 while
23+
preserving HSM (Hardware Security Module) integration, specifically
24+
for Proteccio HSM environments.
25+
company: Red Hat, Inc.
26+
license: Apache-2.0
27+
min_ansible_version: "2.14"
28+
platforms:
29+
- name: Fedora
30+
versions:
31+
- 37
32+
- 38
33+
- 39
34+
- 40
35+
- name: CentOS
36+
versions:
37+
- 9
38+
- name: RHEL
39+
versions:
40+
- 9
41+
42+
dependencies: []

0 commit comments

Comments
 (0)