Skip to content

Commit 22eded5

Browse files
committed
vault: Support generating external TLS certificates for testing
These should not generally be used in production, since the CA is self-signed.
1 parent d883f21 commit 22eded5

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed

doc/source/configuration/vault.rst

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,30 @@ Setup Vault HA on the overcloud hosts
137137
Certificates generation
138138
=======================
139139

140+
Create the external TLS certificates (testing only)
141+
---------------------------------------------------
142+
143+
Typically external API TLS certificates should be generated by a organisation's trusted internal or third-party CA.
144+
For test and development purposes it is possible to use Vault as a CA for the external API.
145+
146+
1. Run the playbook
147+
148+
.. code-block::
149+
150+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/vault-generate-test-external-tls.yml
151+
152+
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.
153+
154+
.. code-block::
155+
156+
ansible-vault encrypt --vault-password-file ~/vault.pass $KAYOBE_CONFIG_PATH/kolla/certificates/haproxy.pem
157+
158+
Or if environments are being used
159+
160+
.. code-block::
161+
162+
ansible-vault encrypt --vault-password-file ~/vault.pass $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/certificates/haproxy.pem
163+
140164
Create the internal TLS certificates
141165
------------------------------------
142166

@@ -189,14 +213,21 @@ Certificates deployment
189213
Enable the required TLS variables in kayobe and kolla
190214
-----------------------------------------------------
191215

192-
1. Set the following in kayobe-config/etc/kayobe/kolla.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla.yml
216+
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
217+
218+
.. code-block::
219+
220+
# Whether TLS is enabled for the external API endpoints. Default is 'no'.
221+
kolla_enable_tls_external: yes
222+
223+
2. Set the following in kayobe-config/etc/kayobe/kolla.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla.yml
193224

194225
.. code-block::
195226
196227
# Whether TLS is enabled for the internal API endpoints. Default is 'no'.
197228
kolla_enable_tls_internal: yes
198229
199-
2. Set the following in etc/kayobe/kolla/globals.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml
230+
3. Set the following in etc/kayobe/kolla/globals.yml or if environments are being used etc/kayobe/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml
200231

201232
.. code-block::
202233
@@ -213,7 +244,7 @@ Enable the required TLS variables in kayobe and kolla
213244
# If using RabbitMQ TLS:
214245
rabbitmq_enable_tls: "yes"
215246
216-
3. Deploy backend and internal TLS
247+
4. Deploy OpenStack
217248

218249
.. warning::
219250

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/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 }}"

0 commit comments

Comments
 (0)