Skip to content

Commit 9d85426

Browse files
authored
Merge pull request #1032 from stackhpc/2023.1-multinode-public-tls
2023.1: Enable TLS for public API in multinode envs, update docker-rally
2 parents 75bae3b + cd9ec7b commit 9d85426

File tree

9 files changed

+128
-7
lines changed

9 files changed

+128
-7
lines changed

.automation.conf/tempest/tempest-ci-multinode.overrides.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ max_microversion = 3.70
3232
build_timeout = 600
3333

3434
[dashboard]
35-
dashboard_url = http://192.168.39.2
35+
dashboard_url = https://192.168.39.2

doc/source/configuration/vault.rst

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,30 @@ Setup Vault HA on the overcloud hosts
149149
Certificates generation
150150
=======================
151151

152+
Create the external TLS certificates (testing only)
153+
---------------------------------------------------
154+
155+
Typically external API TLS certificates should be generated by a organisation's trusted internal or third-party CA.
156+
For test and development purposes it is possible to use Vault as a CA for the external API.
157+
158+
1. Run the playbook
159+
160+
.. code-block::
161+
162+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/vault-generate-test-external-tls.yml
163+
164+
2. Use ansible-vault to encrypt the PEM bundle in $KAYOBE_CONFIG_PATH/kolla/certificates/haproxy.pem. Commit the PEM bundle to the kayobe configuration.
165+
166+
.. code-block::
167+
168+
ansible-vault encrypt --vault-password-file ~/vault.pass $KAYOBE_CONFIG_PATH/kolla/certificates/haproxy.pem
169+
170+
Or if environments are being used
171+
172+
.. code-block::
173+
174+
ansible-vault encrypt --vault-password-file ~/vault.pass $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/certificates/haproxy.pem
175+
152176
Create the internal TLS certificates
153177
------------------------------------
154178

@@ -201,14 +225,23 @@ Certificates deployment
201225
Enable the required TLS variables in kayobe and kolla
202226
-----------------------------------------------------
203227

204-
1. Set the following in kayobe-config/etc/kayobe/kolla.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla.yml
228+
1. If using Vault as a CA for the external API, set the following in kayobe-config/etc/kayobe/kolla.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla.yml
229+
230+
.. code-block::
231+
232+
# Whether TLS is enabled for the external API endpoints. Default is 'no'.
233+
kolla_enable_tls_external: yes
234+
235+
See :ref:`tempest-cacert` for information on adding CA certificates to the trust store when running Tempest.
236+
237+
2. Set the following in kayobe-config/etc/kayobe/kolla.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla.yml
205238

206239
.. code-block::
207240
208241
# Whether TLS is enabled for the internal API endpoints. Default is 'no'.
209242
kolla_enable_tls_internal: yes
210243
211-
2. Set the following in etc/kayobe/kolla/globals.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml
244+
3. Set the following in etc/kayobe/kolla/globals.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml
212245

213246
.. code-block::
214247
@@ -225,7 +258,7 @@ Enable the required TLS variables in kayobe and kolla
225258
# If using RabbitMQ TLS:
226259
rabbitmq_enable_tls: "yes"
227260
228-
3. Deploy backend and internal TLS
261+
4. Deploy OpenStack
229262

230263
.. warning::
231264

doc/source/operations/tempest.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,25 @@ ever contain one host. The seed is usually used as the tempest runner however
251251
it is also common to use the Ansible control host or an infrastructure VM. The
252252
main requirement of the host is that it can reach the OpenStack API.
253253

254+
.. _tempest-cacert:
255+
256+
Tempest CA certificate
257+
----------------------
258+
259+
If your public OpenStack API uses TLS with a Certificate Authority (CA) that is
260+
not trusted by the Python CA trust store, it may be necessary to add a CA
261+
certificate to the trust store in the container that runs Tempest. This can be
262+
done by defining a ``tempest_cacert`` Ansible variable to a path containing the
263+
CA certificate. You may wish to use ``kayobe_config_path`` or
264+
``kayobe_env_config_path`` to be agnostic to the path where kayobe-config is
265+
mounted within the container. For example:
266+
267+
.. code-block:: yaml
268+
:caption: ``etc/kayobe/tempest.yml``
269+
270+
# Add the Vault CA certificate to the rally container when running tempest.
271+
tempest_cacert: "{{ kayobe_env_config_path }}/kolla/certificates/ca/vault.crt"
272+
254273
Running Tempest
255274
===============
256275

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
- name: Generate external API certificate (for testing only)
3+
hosts: controllers
4+
run_once: true
5+
vars:
6+
vault_api_addr: "https://{{ kolla_internal_fqdn }}:8200"
7+
# NOTE: Using the same CA as internal TLS.
8+
vault_intermediate_ca_name: "OS-TLS-INT"
9+
tasks:
10+
- name: Include Vault keys
11+
include_vars:
12+
file: "{{ kayobe_env_config_path }}/vault/overcloud-vault-keys.json"
13+
name: vault_keys
14+
15+
- name: Issue a certificate for external TLS
16+
hashivault_pki_cert_issue:
17+
url: "{{ vault_api_addr }}"
18+
ca_cert: "{{ '/etc/pki/tls/certs/ca-bundle.crt' if ansible_facts.os_family == 'RedHat' else '/usr/local/share/ca-certificates/OS-TLS-ROOT.crt' }}"
19+
token: "{{ vault_keys.root_token }}"
20+
mount_point: "{{ vault_intermediate_ca_name }}"
21+
role: "{{ overcloud_vault_pki_external_tls_role_name }}"
22+
common_name: "{% if kolla_external_fqdn != kolla_external_vip_address %}{{ kolla_external_fqdn }}{% endif %}"
23+
extra_params:
24+
ip_sans: "{{ kolla_external_vip_address }}"
25+
register: external_cert
26+
27+
- name: Ensure certificates directory exists
28+
file:
29+
path: "{{ kayobe_env_config_path }}/kolla/certificates"
30+
state: directory
31+
delegate_to: localhost
32+
33+
- name: Ensure CA certificates directory exists
34+
file:
35+
path: "{{ kayobe_env_config_path }}/kolla/certificates/ca"
36+
state: directory
37+
delegate_to: localhost
38+
39+
- name: Copy external API PEM bundle
40+
no_log: true
41+
copy:
42+
dest: "{{ kayobe_env_config_path }}/kolla/certificates/haproxy.pem"
43+
content: |
44+
{{ external_cert.data.certificate }}
45+
{{ external_cert.data.issuing_ca }}
46+
{{ external_cert.data.private_key }}
47+
mode: 0600
48+
delegate_to: localhost
49+
50+
- name: Copy root CA
51+
copy:
52+
src: "{{ kayobe_env_config_path }}/vault/OS-TLS-ROOT.pem"
53+
dest: "{{ kayobe_env_config_path }}/kolla/certificates/ca/vault.crt"
54+
mode: 0600
55+
delegate_to: localhost

etc/kayobe/environments/ci-multinode/kolla.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ kolla_enable_designate: true
88
kolla_enable_redis: true
99
kolla_enable_barbican: true
1010

11-
# The multinode environment supports Backend and internal TLS , but it must be
12-
# enabled in the correct order. See
11+
# The multinode environment supports backend, external and internal TLS , but
12+
# it must be enabled in the correct order. See
1313
# https://stackhpc-kayobe-config.readthedocs.io/en/stackhpc-yoga/configuration/vault.html
1414
# for details.
15+
# kolla_enable_tls_external: true
1516
# kolla_enable_tls_internal: true
1617

18+
kolla_public_openrc_cacert: "{{ '/etc/pki/tls/certs/ca-bundle.crt' if os_distribution in ['centos', 'rocky'] else '/etc/ssl/certs/ca-certificates.crt' }}"
19+
kolla_admin_openrc_cacert: "{{ kolla_public_openrc_cacert }}"
20+
1721
# The multinode environment supports Manila but it is not enabled by default.
1822
# kolla_enable_manila: true
1923
# kolla_enable_manila_backend_cephfs_native: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Add the Vault CA certificate to the rally container when running tempest.
3+
tempest_cacert: "{{ kayobe_env_config_path }}/kolla/certificates/ca/vault.crt"

etc/kayobe/inventory/group_vars/all/vault

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ overcloud_vault_pki_internal_tls_role_name: "{{ overcloud_vault_pki_default_role
6464
# Overcloud Vault PKI Backend TLS Role name
6565
overcloud_vault_pki_backend_tls_role_name: "{{ overcloud_vault_pki_default_role_name }}"
6666

67+
# Overcloud Vault PKI External TLS Role name (for testing only)
68+
overcloud_vault_pki_external_tls_role_name: "{{ overcloud_vault_pki_default_role_name }}"
69+
6770
# Overcloud Vault PKI Roles definition
6871
overcloud_vault_pki_roles:
6972
- name: "{{ overcloud_vault_pki_default_role_name }}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Supports adding CA certificates to the Tempest container trust store.

0 commit comments

Comments
 (0)