Skip to content

Commit c598131

Browse files
committed
Simplify the role
Lets take all the dependencies on a running lunaclient VM out. We suspect that with the ip checking turned off, we can use any subject in the client certs anyway, as long as the cert is uploaded to the HSM (and registered to a client). This simplifies things considerably - and makes the role more reusable by a deployer as a standalone role. Instead, we'll need the relevant bits uploaded somewhere for the deployer to retrieve.
1 parent 7988522 commit c598131

File tree

10 files changed

+81
-230
lines changed

10 files changed

+81
-230
lines changed

docs/dictionary/en-custom.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ bootmacaddress
4646
bootmode
4747
buildah
4848
buildpkgs
49+
cacert
4950
cacheable
5051
cci
5152
ccitredhat
@@ -305,6 +306,7 @@ mellanox
305306
metallb
306307
metalsmith
307308
mgmt
309+
minclient
308310
mins
309311
minsizegigabytes
310312
mlnx
@@ -397,6 +399,7 @@ params
397399
passwd
398400
passwordless
399401
pastebin
402+
pem
400403
pkgs
401404
pki
402405
png

hooks/playbooks/barbican-cleanup-luna.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

hooks/playbooks/barbican-enable-luna.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
---
2-
- name: Add lunaclient to inventory
3-
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4-
tasks:
5-
- name: Get lunaclient key
6-
ansible.builtin.get_url:
7-
url: "{{ cifmw_hsm_lunaclient_key }}"
8-
dest: "{{ ansible_user_dir }}/.ssh/lunaclient"
9-
mode: "0400"
10-
- name: Add lunaclient VM to inventory
11-
ansible.builtin.add_host:
12-
name: "{{ cifmw_hsm_lunaclient_vm }}"
13-
ansible_user: "{{ cifmw_hsm_lunaclient_user }}"
14-
ansible_ssh_private_key_file: "{{ ansible_user_dir }}/.ssh/lunaclient"
15-
ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
16-
172
- name: Create modified barbican image and get secrets
18-
hosts: "{{ cifmw_hsm_lunaclient_vm }}"
3+
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
194
tasks:
205
- name: Include hsm_prep role
216
ansible.builtin.include_role:
227
name: hsm_prep
238
vars:
24-
cifmw_hsm_client_ip: "{{ hostvars[ cifmw_hsm_client_machine ].ansible_host }}"
9+
cifmw_hsm_src_image_registry: "{{ content_provider_registry_ip }}:5001"
10+
cifmw_hsm_src_image_namepace: "{{ cifmw_set_openstack_containers_namespace }}"
11+
cifmw_hsm_src_image_tag: "{{ cifmw_update_extras['cifmw_set_openstack_containers_tag'] }}"
12+
cifmw_hsm_dest_image_registry: "{{ content_provider_registry_ip }}:5001"
13+
cifmw_hsm_dest_image_namepace: "{{ cifmw_set_openstack_containers_namespace }}"
14+
cifmw_hsm_dest_image_tag: "{{ cifmw_update_extras['cifmw_set_openstack_containers_tag'] }}-luna"
2515

2616
- name: Create kustomization to use update barbican to use luna
2717
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
@@ -30,7 +20,6 @@
3020
vars:
3121
certs_secret: "{{ cifmw_hsm_luna_cert_secret | default('barbican-luna-certs', true) }}"
3222
login_secret: "{{ cifmw_hsm_login_secret | default('hsm-login', true) }}"
33-
cifmw_hsm_client_ip: "{{ hostvars[ cifmw_hsm_client_machine ].ansible_host }}"
3423
ansible.builtin.copy:
3524
dest: "{{ cifmw_basedir }}/artifacts/manifests/kustomizations/controlplane/93-barbican-luna.yaml"
3625
content: |-

roles/hsm_prep/README.md

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# HSM Role
22

3-
In order to use HSMs, the barbican images need to be customized to include the HSM software. For now, this is something
4-
that we expect customers to do with scripts that we will provide as part of the barbican-operator code.
3+
In order to use HSMs, the barbican images need to be customized to include the HSM software.
54

65
The purpose of this role is to:
76
* Generate new images for the barbican-api and barbican-worker containing the HSM software
@@ -10,21 +9,18 @@ The purpose of this role is to:
109

1110
For the Lunasa, we expect some preparatory steps to be completed prior to execution in order for the
1211
role to complete successfully.
13-
* We expect a VM that contains the Lunasa client software and that is registered as a lunasa client.
14-
This VM should contain the following contents:
15-
* The contents of the minimal linux client in a zipped tar file.
16-
* The lunasa binaries that need to be added to the image under a specified directory.
17-
* The lunasa HSM server cert.
18-
* The above contents will be fetched by the role.
19-
* The VM will be used to generate client certificates. For this, we will need the cifmw_hsm_client_ip , which
20-
is the VM of the hypervisor hosting the openshift node. If a cert has already been generated, then
21-
that certificate will be retrieved instead.
12+
* The lunasa software is uploaded somewhere and will be fetched by the role
13+
* The contents of the minimal linux client in a zipped tar file should be made available at cifmw_hsm_luna_minclient_src.
14+
* The lunasa binaries that need to be added to the image are made available at cifmw_hsm_luna_binaries_src.
15+
* The lunasa HSM cacert file is made available at cifmw_hsm_luna_server_cert_src. For an HA configuration,
16+
this will be a concatenation of all the server certs for the servers in the HA partition.
17+
* The client certificate and key made available at cifmw_hsm_luna_client_cert_src. The files are expected
18+
to be of the form "(cifmw_hsm_client_ip)".pem and "(cifmw_hsm_client_ip)"Key.pem
2219
* The certs will be retrieved and stored in a secret (cifmw_hsm_luna_cert_secret)
2320
* The password to log into the HSM partition will be stored in a secret (cifmw_hsm_login_secret)
24-
* As input to this role, we will require the ssh connection details and credentials for this VM.
2521

26-
A minimal (one that takes the defaults) invocation of this role is shown below, where the lunaclient
27-
is the running client VM described above.
22+
A minimal (one that takes the defaults) invocation of this role is shown below. In this case, the lunaclient
23+
software and certs are stored locally under /opt/luna.
2824

2925
- name: Set up Luna
3026
hosts: lunaclient
@@ -34,11 +30,7 @@ is the running client VM described above.
3430
- cert_prep
3531
- secret_prep
3632
vars:
37-
cifmw_hsm_admin_password: "<HSM admin password>"
38-
cifmw_hsm_server_ip: "IP of HSM"
3933
cifmw_hsm_client_ip: "IP of the client - this could be the hypervisor where the Openshift nodes run"
40-
cifmw_hsm_luna_partition: "HSM partition for the client to join"
41-
cifmw_hsm_partition_password: "<HSM partition password>"
4234

4335
Note that tags have been provided to allow the caller to select specific operations. This may be necessary
4436
because different operations may need to executed in different CI jobs. The current tags available are:
@@ -48,28 +40,26 @@ image_prep, cert_prep, secret_prep, cleanup
4840

4941
### HSM Details
5042
* `cifmw_hsm_hsmtype`: (String) The type of HSM required. Currently, only "luna" is supported. Default value: `luna`
51-
* `cifmw_hsm_admin_user`: (String) The user to log into the HSM. Default value: `admin`
52-
* `cifmw_hsm_admin_password`: (String) The password to log into the HSM.
53-
* `cifmw_hsm_server_ip`: (String) ip address or hostname of the HSM
54-
* `cifmw_hsm_partition_password: (String) The password to log into the HSM partition
5543
* `cifmw_hsm_login_secret`: (String) The secret to store the password to log into the HSM partition. Default: `hsm-login`
5644

57-
### Barbican Image and Details to get buildah script
58-
* `cifmw_hsm_barbican_operator_repo`: (String) Repo for barbican-operator. Default value: "https://github.com/openstack-k8s-operators/barbican-operator.git"
59-
* `cifmw_hsm_barbican_operator_version`: (String) Version for barbican-operator. Default value: "main"
60-
* `cifmv_hsm_barbican_image_namespace`: (String) Namespace for barbican-operator source image. Default value: "podified-antelope-centos9"
61-
* `cifmw_hsm_barbican_image_tag`: (String) Tag for barbican-operator source image. Default value: "current-podified"
62-
6345
### Role Parameters
6446
* `cifmw_hsm_cleanup`: (Boolean) Delete all resources created by the role at the end of the testing. Default value: `false`
6547
* `cifmw_hsm_working_dir`: (String) Working directory to store artifacts. Default value: `/tmp/hsm-prep-working-dir`
6648
* `cifmw_hsm_client_ip`: (String) ip address or hostname of the client VM
6749

50+
### Image Details
51+
* `cifmw_hsm_barbican_src_image_registry`: (String) Registry of the source image. Default value: `quay.io`
52+
* `cifmw_hsm_barbican_src_image_namespace: (String) Namespace of the source image. Default value: `podified-antelope-centos9`
53+
* `cifmw_hsm_barbican_src_image_tag: (String) Tag of the source image. Default value: `current-podified`
54+
* `cifmw_hsm_barbican_dest_image_registry`: (String) Registry of the modified image. Default value: `quay.io`
55+
* `cifmw_hsm_barbican_dest_image_namespace: (String) Namespace of the modified image. Default value: `podified-antelope-centos9`
56+
* `cifmw_hsm_barbican_dest_image_tag: (String) Tag of the modified image. Default value: `current-podified-luna`
57+
6858
### Luna Parameters
69-
* `cifmw_hsm_luna_minclient_src`: (String) Location of linux minimal client tarball on the luna client VM. Default value: `/opt/data/Linux-Minimal-Client.tar.gz`
70-
* `cifmw_hsm_luna_binaries_src`: (String) Location of the luna binaries on the luna client VM. Default value: `/opt/data/bin`
71-
* `cifmw_hsm_luna_server_cert_src`: (String) Location of HSM server cert on the luna client VM. Default value: `/usr/safenet/lunaclient/cert/server`
72-
* `cifmw_hsm_luna_client_cert_src`: (String) Location of HSM client cert on the luna client VM. Default value: `/usr/safenet/lunaclient/cert/client`
59+
* `cifmw_hsm_luna_minclient_src`: (String) Location of linux minimal client tarball. Default value: `file:///opt/luna/Linux-Minimal-Client.tar.gz`
60+
* `cifmw_hsm_luna_binaries_src`: (String) Location of the luna binaries. Default value: `file:///opt/luna/bin`
61+
* `cifmw_hsm_luna_server_cert_src`: (String) Location of HSM server CA cert. Default value: `file:///opt/luna/cert/server/cacert.pem`
62+
* `cifmw_hsm_luna_client_cert_src`: (String) Location of HSM client certs. Default value: `file:///opt/luna/cert/client`
63+
* `cifmw_hsm_server_ca_file`: (String) Name of the cacert file in the container. Default value: `cacert.pem`
7364
* `cifmw_hsm_luna_cert_secret`: (String) Name of the secret that stores all of the needed certs for luna. Default value: `barbican-luna-certs`
7465
* `cifmw_hsm_luna_cert_secret_namespace`: (String) Namespace of the secret that stores all of the needed certs for luna. Default value: `openstack`
75-
* `cifmw_hsm_luna_partition`: (String) HSM partition for the client to join.

roles/hsm_prep/defaults/main.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,23 @@ cifmw_hsm_hsmtype: "luna"
2222
cifmw_hsm_admin_user: "admin"
2323
cifmw_hsm_login_secret: "hsm-login"
2424

25-
### Barbican Image and Details to get buildah script
26-
cifmw_hsm_barbican_operator_repo: "https://github.com/openstack-k8s-operators/barbican-operator.git"
27-
cifmw_hsm_barbican_operator_version: "main"
28-
2925
### Role Parameters
3026
cifmw_hsm_cleanup: false
3127
cifmw_hsm_working_dir: "/tmp/hsm-prep-working-dir"
3228

3329
### Luna Parameters
34-
cifmw_hsm_luna_minclient_src: "/opt/data/Linux-Minimal-Client.tar.gz"
35-
cifmw_hsm_luna_binaries_src: "/opt/data/bin"
36-
cifmw_hsm_luna_server_cert_src: "/usr/safenet/lunaclient/cert/server"
37-
cifmw_hsm_luna_client_cert_src: "/usr/safenet/lunaclient/cert/client"
30+
cifmw_hsm_luna_minclient_src: "file:///opt/luna/Linux-Minimal-Client.tar.gz"
31+
cifmw_hsm_luna_binaries_src: "file:///opt/luna/bin/"
32+
cifmw_hsm_luna_server_cert_src: "file:///opt/luna/cert/server/cacert.pem"
33+
cifmw_hsm_luna_client_cert_src: "file:///opt/luna/cert/client/"
34+
cifmw_hsm_server_ca_file: "cacert.pem"
3835
cifmw_hsm_luna_cert_secret: "barbican-luna-certs"
3936
cifmw_hsm_luna_cert_secret_namespace: "openstack"
4037

4138
## Image details
42-
cifmv_hsm_barbican_image_registry: "quay.io"
43-
cifmv_hsm_barbican_image_namespace: "podified-antelope-centos9"
44-
cifmw_hsm_barbican_image_tag: "current-podified"
45-
cifmw_hsm_barbican_final_image_tag: "current-podified-luna"
39+
cifmw_hsm_barbican_src_image_registry: "quay.io"
40+
cifmw_hsm_barbican_src_image_namespace: "podified-antelope-centos9"
41+
cifmw_hsm_barbican_src_image_tag: "current-podified"
42+
cifmw_hsm_barbican_dest_image_registry: "quay.io"
43+
cifmw_hsm_barbican_dest_image_namespace: "podified-antelope-centos9"
44+
cifmw_hsm_barbican_dest_image_tag: "current-podified-luna"

roles/hsm_prep/files/image_add_luna_minimal_client.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ set -x
99
set -o errexit
1010
set -o pipefail
1111

12-
BARBICAM_IMAGE_REGISTRY=${BARBICAN_IMAGE_REGISTRY:-"quay.io"}
13-
BARBICAN_IMAGE_NAMESPACE=${BARBICAN_IMAGE_NAMESPACE:-"podified-antelope-centos9"}
14-
BARBICAN_IMAGE_TAG=${BARBICAN_IMAGE_TAG:-"current-podified"}
15-
BARBICAN_API_IMAGE="$BARBICAM_IMAGE_REGISTRY/$BARBICAN_IMAGE_NAMESPACE/openstack-barbican-api:$BARBICAN_IMAGE_TAG"
16-
BARBICAN_WORKER_IMAGE="$BARBICAM_IMAGE_REGISTRY/$BARBICAN_IMAGE_NAMESPACE/openstack-barbican-worker:$BARBICAN_IMAGE_TAG"
17-
BARBICAM_FINAL_IMAGE_TAG_X=${BARBICAN_FINAL_IMAGE_TAG:-"current-podified-luna"}
18-
BARBICAN_API_FINAL_IMAGE="$BARBICAM_IMAGE_REGISTRY/$BARBICAN_IMAGE_NAMESPACE/openstack-barbican-api:${BARBICAM_FINAL_IMAGE_TAG_X}"
19-
BARBICAN_WORKER_FINAL_IMAGE="$BARBICAM_IMAGE_REGISTRY/$BARBICAN_IMAGE_NAMESPACE/openstack-barbican-worker:${BARBICAM_FINAL_IMAGE_TAG_X}"
12+
BARBICAM_SRC_IMAGE_REGISTRY=${BARBICAN_SRC_IMAGE_REGISTRY:-"quay.io"}
13+
BARBICAN_SRC_IMAGE_NAMESPACE=${BARBICAN_SRC_IMAGE_NAMESPACE:-"podified-antelope-centos9"}
14+
BARBICAN_SRC_IMAGE_TAG=${BARBICAN_SRC_IMAGE_TAG:-"current-podified"}
15+
BARBICAN_SRC_API_IMAGE="$BARBICAM_SRC_IMAGE_REGISTRY/$BARBICAN_SRC_IMAGE_NAMESPACE/openstack-barbican-api:$BARBICAN_SRC_IMAGE_TAG"
16+
BARBICAN_SRC_WORKER_IMAGE="$BARBICAM_SRC_IMAGE_REGISTRY/$BARBICAN_SRC_IMAGE_NAMESPACE/openstack-barbican-worker:$BARBICAN_SRC_IMAGE_TAG"
17+
18+
BARBICAM_DEST_IMAGE_REGISTRY=${BARBICAN_DEST_IMAGE_REGISTRY:-"quay.io"}
19+
BARBICAN_DEST_IMAGE_NAMESPACE=${BARBICAN_DEST_IMAGE_NAMESPACE:-"podified-antelope-centos9"}
20+
BARBICAN_DEST_IMAGE_TAG=${BARBICAN_DEST_IMAGE_TAG:-"current-podified"}
21+
BARBICAN_DEST_API_IMAGE="$BARBICAM_DEST_IMAGE_REGISTRY/$BARBICAN_DEST_IMAGE_NAMESPACE/openstack-barbican-api:$BARBICAN_DEST_IMAGE_TAG"
22+
BARBICAN_DEST_WORKER_IMAGE="$BARBICAM_DEST_IMAGE_REGISTRY/$BARBICAN_DEST_IMAGE_NAMESPACE/openstack-barbican-worker:$BARBICAN_DEST_IMAGE_TAG"
2023

2124
# LUNA_LINUX_MINIMAL_CLIENT_DIR - location of the "linux-minimal" directory
2225
# in your client media. This could be a path to a mounted ISO or a path to
@@ -49,5 +52,5 @@ function install_client() {
4952
buildah rm $container
5053
}
5154

52-
install_client $BARBICAN_API_IMAGE $BARBICAN_API_FINAL_IMAGE
53-
install_client $BARBICAN_WORKER_IMAGE $BARBICAN_WORKER_FINAL_IMAGE
55+
install_client $BARBICAN_SRC_API_IMAGE $BARBICAN_DEST_API_IMAGE
56+
install_client $BARBICAN_SRC_WORKER_IMAGE $BARBICAN_DEST_WORKER_IMAGE

roles/hsm_prep/tasks/cleanup.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,6 @@
99
ansible.builtin.debug:
1010
msg: "Running cleanup tasks here"
1111

12-
- name: Set fact for client_name
13-
ansible.builtin.set_fact:
14-
client_name: "{{ cifmw_hsm_client_ip }}"
15-
16-
- name: Check for existing HSM client
17-
ansible.builtin.shell: >
18-
sshpass -p '{{ cifmw_hsm_admin_password }}'
19-
ssh -o StrictHostKeyChecking=false -c aes256-cbc
20-
{{ cifmw_hsm_admin_user }}@{{ cifmw_hsm_server_ip }}
21-
-C client list
22-
register: client_list
23-
24-
- name: Delete existing client when rotating certs
25-
ansible.builtin.shell: >
26-
sshpass -p '{{ cifmw_hsm_admin_password }}'
27-
ssh -c aes256-cbc {{ cifmw_hsm_admin_user }}@{{ cifmw_hsm_server_ip }}
28-
-C "client delete -f -c {{ client_name }}"
29-
when:
30-
- client_name in client_list.stdout
31-
3212
- name: Remove the working directory
3313
delegate_to: localhost
3414
become: true

roles/hsm_prep/tasks/generate_luna_client_certs.yaml

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)