Skip to content

Commit dcec3e0

Browse files
author
Mauricio Harley
committed
Add minimal HSM support to barbican_adoption role
Extend the existing barbican_adoption role with minimal HSM support for Proteccio integration. Fixes: OSPRH-18981 Signed-off-by: Mauricio Harley <mharley@redhat.com>
1 parent 8386d79 commit dcec3e0

File tree

8 files changed

+108
-1
lines changed

8 files changed

+108
-1
lines changed

tests/config.env.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Minimal environment configuration for HSM adoption
2+
# Copy this to config.env and modify as needed
3+
4+
# HSM Configuration
5+
BARBICAN_HSM_ENABLED=false

tests/hsm_vars/common.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Common HSM variables
3+
internalapi_prefix: "172.17.0"

tests/hsm_vars/proteccio.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Minimal Proteccio HSM configuration
3+
barbican_hsm_enabled: true

tests/inventory.proteccio.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
all:
3+
hosts:
4+
localhost:
5+
ansible_connection: local
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Barbican HSM Adoption
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
vars_files:
7+
- hsm_vars/proteccio.yml
8+
roles:
9+
- barbican_adoption

tests/roles/barbican_adoption/defaults/main.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
# HSM support flag
3+
barbican_hsm_enabled: false
4+
25
barbican_patch: |
36
spec:
47
barbican:
@@ -39,3 +42,50 @@ barbican_patch: |
3942
barbicanKeystoneListener:
4043
replicas: 1
4144
barbican_retry_delay: 5
45+
46+
barbican_hsm_patch: |
47+
spec:
48+
barbican:
49+
enabled: true
50+
apiOverride:
51+
route: {}
52+
template:
53+
databaseInstance: openstack
54+
databaseAccount: barbican
55+
rabbitMqClusterName: rabbitmq
56+
secret: osp-secret
57+
simpleCryptoBackendSecret: osp-secret
58+
serviceAccount: barbican
59+
serviceUser: barbican
60+
passwordSelectors:
61+
database: BarbicanDatabasePassword
62+
service: BarbicanPassword
63+
simplecryptokek: BarbicanSimpleCryptoKEK
64+
customServiceConfig: |
65+
[p11_crypto_plugin]
66+
plugin_name = PKCS11
67+
library_path = {{ proteccio_library_path | default('/opt/tw_proteccio/lib/libnethsm.so') }}
68+
token_labels = {{ proteccio_hsm_tokens | default(['VHSM1']) | join(',') }}
69+
mkek_label = {{ proteccio_mkek_name | default('adoption_mkek_1') }}
70+
hmac_label = {{ proteccio_hmac_name | default('adoption_hmac_1') }}
71+
encryption_mechanism = CKM_AES_CBC
72+
hmac_key_type = CKK_GENERIC_SECRET
73+
hmac_keygen_mechanism = CKM_GENERIC_SECRET_KEY_GEN
74+
hmac_mechanism = CKM_SHA256_HMAC
75+
key_wrap_mechanism = CKM_AES_CBC_PAD
76+
key_wrap_generate_iv = true
77+
always_set_cka_sensitive = true
78+
os_locking_ok = false
79+
login = {{ proteccio_login_password | default('') }}
80+
globalDefaultSecretStore: pkcs11
81+
enabledSecretStores: ["simple_crypto", "pkcs11"]
82+
pkcs11:
83+
loginSecret: hsm-login
84+
clientDataSecret: proteccio-data
85+
clientDataPath: /etc/proteccio
86+
barbicanAPI:
87+
replicas: 1
88+
barbicanWorker:
89+
replicas: 1
90+
barbicanKeystoneListener:
91+
replicas: 1

tests/roles/barbican_adoption/tasks/main.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
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: deploy podified Barbican
8+
- name: deploy podified Barbican (standard)
99
ansible.builtin.shell: |
1010
{{ shell_header }}
1111
{{ oc_header }}
1212
oc patch openstackcontrolplane openstack --type=merge --patch '{{ barbican_patch }}'
13+
when: not barbican_hsm_enabled|default(false)
14+
15+
- name: deploy podified Barbican (HSM)
16+
ansible.builtin.shell: |
17+
{{ shell_header }}
18+
{{ oc_header }}
19+
oc patch openstackcontrolplane openstack --type=merge --patch '{{ barbican_hsm_patch }}'
20+
when: barbican_hsm_enabled|default(false)
1321

1422
- name: wait for Barbican to start up
1523
ansible.builtin.shell: |

tests/roles/development_environment/tasks/main.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,30 @@
5454
prelaunch_test_instance: "{{ prelaunch_test_instance }}"
5555
ping_test: "{{ ping_test }}"
5656

57+
- name: Debug - Check if we're trying to create Barbican secret
58+
ansible.builtin.debug:
59+
msg:
60+
- "prelaunch_test_instance: {{ prelaunch_test_instance|bool }}"
61+
- "prelaunch_barbican_secret: {{ prelaunch_barbican_secret|default(false) }}"
62+
- "Will attempt to create secret: {{ prelaunch_test_instance|bool and prelaunch_barbican_secret|default(false) }}"
63+
64+
- name: Debug - Check Barbican endpoint on source cloud
65+
no_log: "{{ use_no_log }}"
66+
when: prelaunch_test_instance|bool and prelaunch_barbican_secret|default(false)
67+
ansible.builtin.shell:
68+
cmd: |
69+
{{ shell_header }}
70+
{{ openstack_command }} endpoint list --service key-manager -f json
71+
register: barbican_endpoint_check
72+
failed_when: false
73+
74+
- name: Debug - Display Barbican endpoint status
75+
when:
76+
- prelaunch_test_instance|bool
77+
- prelaunch_barbican_secret|default(false)
78+
ansible.builtin.debug:
79+
msg: "{{ 'Barbican endpoint found' if barbican_endpoint_check.rc == 0 else 'ERROR: No Barbican endpoint found on source cloud!' }}"
80+
5781
- name: creates Barbican secret
5882
no_log: "{{ use_no_log }}"
5983
when: prelaunch_test_instance|bool and prelaunch_barbican_secret|default(false)

0 commit comments

Comments
 (0)