Skip to content

Commit 3f7277b

Browse files
author
Mauricio Harley
committed
Add support for custom Barbican images and parameterized HSM secrets
This change adds support for: - Custom Barbican API and Worker container images via barbican_custom_api_image and barbican_custom_worker_image variables - Parameterized HSM secret names via proteccio_login_secret_name and proteccio_client_data_secret_name variables This enables adoption scenarios where Barbican requires custom images with HSM client libraries (e.g., Proteccio) installed. Signed-off-by: Mauricio Harley <mharley@redhat.com>
1 parent dcec3e0 commit 3f7277b

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

tests/roles/backend_services/tasks/main.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,32 @@
9393
args:
9494
chdir: "{{ dpa_tests_dir }}/config"
9595

96+
- name: Get OpenStackVersion resource name for custom Barbican images
97+
when: >-
98+
(barbican_custom_api_image is defined and barbican_custom_api_image) or
99+
(barbican_custom_worker_image is defined and barbican_custom_worker_image)
100+
ansible.builtin.shell: |
101+
{{ shell_header }}
102+
{{ oc_header }}
103+
oc get openstackversions -o jsonpath='{.items[0].metadata.name}'
104+
register: openstack_version_name
105+
changed_when: false
106+
failed_when: openstack_version_name.stdout == ""
107+
108+
- name: Patch OpenStackVersion with custom Barbican images
109+
when: >-
110+
(barbican_custom_api_image is defined and barbican_custom_api_image) or
111+
(barbican_custom_worker_image is defined and barbican_custom_worker_image)
112+
ansible.builtin.shell: |
113+
{{ shell_header }}
114+
{{ oc_header }}
115+
{% if barbican_custom_api_image is defined and barbican_custom_api_image %}
116+
oc patch openstackversion {{ openstack_version_name.stdout }} --type=merge -p '{"spec":{"customContainerImages":{"barbicanAPIImage":"{{ barbican_custom_api_image }}"}}}'
117+
{% endif %}
118+
{% if barbican_custom_worker_image is defined and barbican_custom_worker_image %}
119+
oc patch openstackversion {{ openstack_version_name.stdout }} --type=merge -p '{"spec":{"customContainerImages":{"barbicanWorkerImage":"{{ barbican_custom_worker_image }}"}}}'
120+
{% endif %}
121+
96122
- name: execute alternative tasks when source env is ODPdO
97123
ansible.builtin.include_tasks: ospdo_backend_services.yaml
98124
when: ospdo_src| bool

tests/roles/barbican_adoption/defaults/main.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ barbican_hsm_patch: |
8080
globalDefaultSecretStore: pkcs11
8181
enabledSecretStores: ["simple_crypto", "pkcs11"]
8282
pkcs11:
83-
loginSecret: hsm-login
84-
clientDataSecret: proteccio-data
83+
loginSecret: {{ proteccio_login_secret_name | default('hsm-login') }}
84+
clientDataSecret: {{ proteccio_client_data_secret_name | default('proteccio-data') }}
8585
clientDataPath: /etc/proteccio
8686
barbicanAPI:
8787
replicas: 1
8888
barbicanWorker:
8989
replicas: 1
9090
barbicanKeystoneListener:
9191
replicas: 1
92+
93+
# HSM secrets configuration
94+
proteccio_login_secret_name: hsm-login
95+
proteccio_client_data_secret_name: proteccio-data
96+
proteccio_login_password: ''

tests/roles/barbican_adoption/tasks/main.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,50 @@
55
CONTROLLER1_SSH="{{ controller1_ssh }}"
66
oc set data secret/osp-secret "BarbicanSimpleCryptoKEK=$($CONTROLLER1_SSH "sudo python3 -c \"import configparser; c = configparser.ConfigParser(); c.read('/var/lib/config-data/puppet-generated/barbican/etc/barbican/barbican.conf'); print(c['simple_crypto_plugin']['kek'])\"")"
77
8+
- name: Create HSM login secret for Barbican
9+
when: barbican_hsm_enabled|default(false)
10+
ansible.builtin.shell: |
11+
{{ shell_header }}
12+
{{ oc_header }}
13+
cat <<EOF | oc apply -f -
14+
apiVersion: v1
15+
kind: Secret
16+
metadata:
17+
name: {{ proteccio_login_secret_name | default('hsm-login') }}
18+
namespace: openstack
19+
type: Opaque
20+
stringData:
21+
PKCS11Pin: "{{ proteccio_login_password | default('') }}"
22+
EOF
23+
24+
- name: Check if HSM client data files exist
25+
when: barbican_hsm_enabled|default(false)
26+
ansible.builtin.stat:
27+
path: /tmp/hsm-prep-working-dir/proteccio_data_secret.yml
28+
register: hsm_data_secret_file
29+
30+
- name: Create HSM client data secret from file
31+
when:
32+
- barbican_hsm_enabled|default(false)
33+
- hsm_data_secret_file.stat.exists|default(false)
34+
ansible.builtin.command: oc apply -f /tmp/hsm-prep-working-dir/proteccio_data_secret.yml
35+
36+
- name: Create empty HSM client data secret if file not found
37+
when:
38+
- barbican_hsm_enabled|default(false)
39+
- not hsm_data_secret_file.stat.exists|default(true)
40+
ansible.builtin.shell: |
41+
{{ shell_header }}
42+
{{ oc_header }}
43+
cat <<EOF | oc apply -f -
44+
apiVersion: v1
45+
kind: Secret
46+
metadata:
47+
name: {{ proteccio_client_data_secret_name | default('proteccio-data') }}
48+
namespace: openstack
49+
type: Opaque
50+
EOF
51+
852
- name: deploy podified Barbican (standard)
953
ansible.builtin.shell: |
1054
{{ shell_header }}

0 commit comments

Comments
 (0)