Skip to content

Commit 8ad0f8a

Browse files
committed
feat: add support for enabling Pulp TLS
Add playbooks, configuration and documentation to support the deployment of Pulp TLS.
1 parent 5707bb2 commit 8ad0f8a

File tree

6 files changed

+138
-3
lines changed

6 files changed

+138
-3
lines changed

doc/source/configuration/openbao.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,40 @@ Enable the required TLS variables in kayobe and kolla
460460
461461
kayobe overcloud host command run --command "systemctl restart kolla-nova_compute-container.service" --become --show-output -l compute
462462
463+
Pulp TLS
464+
========
465+
466+
.. warning::
467+
468+
For clouds in production consider the impact of enabling TLS on specific hosts as Docker daemon will be restarted and this will disrupt deployments of Ceph Reef and older.
469+
470+
To enable TLS for Pulp we first need to generate the certificates and the proceed to configure all hosts that use Pulp to add the root CA to their truststore.
471+
472+
1. Generate the certificate
473+
474+
.. code-block::
475+
476+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/pulp/pulp-generate-certificate.yml
477+
478+
2. Copy CA to truststore
479+
480+
.. code-block::
481+
482+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/deployment/copy-ca-to-hosts.yml
483+
484+
3. Enable TLS for Pulp in pulp.yml
485+
486+
.. code-block::
487+
488+
# Whether to enable TLS for Pulp.
489+
pulp_enable_tls: true
490+
491+
4. Redeploy Pulp
492+
493+
.. code-block::
494+
495+
kayobe seed service reconfigure -t seed-deploy-containers -kt none
496+
463497
Barbican integration
464498
====================
465499

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
- name: Install certificate authorities and update trust
3+
hosts: overcloud:seed:seed-hypervisor
4+
# Avoid using facts because this may be used as a pre overcloud host
5+
# configure hook, and we don't want to populate the fact cache (if one is in
6+
# use) with the bootstrap user's context.
7+
gather_facts: false
8+
tags:
9+
- install-ca
10+
vars:
11+
ansible_user: "{{ bootstrap_user }}"
12+
# We can't assume that a virtualenv exists at this point, so use the system
13+
# python interpreter.
14+
ansible_python_interpreter: /usr/bin/python3
15+
# Work around no known_hosts entry on first boot.
16+
ansible_ssh_common_args: -o StrictHostKeyChecking=no
17+
# Don't assume facts are present.
18+
os_family: "{{ ansible_facts.os_family | default('Debian' if os_distribution == 'ubuntu' else 'RedHat') }}"
19+
become: true
20+
tasks:
21+
- name: Install certificate authorities on RedHat based distributions
22+
when: os_family == 'RedHat'
23+
block:
24+
- name: Copy certificate authorities on RedHat family systems (Rocky, RHEL, CentOS)
25+
ansible.builtin.copy:
26+
src: "{{ kayobe_env_config_path }}/openbao/{{ item }}.pem"
27+
dest: "/etc/pki/ca-trust/source/anchors/{{ item }}.crt"
28+
mode: "0644"
29+
loop:
30+
- "OS-TLS-ROOT"
31+
32+
- name: Update CA trust on RedHat family systems
33+
ansible.builtin.command: "update-ca-trust"
34+
35+
- name: Install certificate authorities on Debian based distributions
36+
when: os_family == 'Debian'
37+
block:
38+
- name: Copy certificate authorities on Debian family systems (Ubuntu, Debian)
39+
ansible.builtin.copy:
40+
src: "{{ kayobe_env_config_path }}/openbao/{{ item }}.pem"
41+
dest: "/usr/local/share/ca-certificates/{{ item }}.crt"
42+
mode: "0644"
43+
loop:
44+
- "OS-TLS-ROOT"
45+
46+
- name: Update CA trust on Debian family systems
47+
ansible.builtin.command: "update-ca-certificates"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
- name: Generate certificates
3+
hosts: seed
4+
run_once: true
5+
vars:
6+
openbao_api_addr: http://127.0.0.1:8200
7+
openbao_intermediate_ca_name: OS-TLS-INT
8+
tasks:
9+
- name: Include OpenBao keys
10+
ansible.builtin.include_vars:
11+
file: "{{ kayobe_env_config_path }}/openbao/seed-openbao-keys.json"
12+
name: openbao_keys
13+
14+
- name: Issue a certificate Pulp
15+
hashivault_pki_cert_issue: # noqa: fqcn
16+
url: "{{ openbao_api_addr }}"
17+
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' }}"
18+
token: "{{ openbao_keys.root_token }}"
19+
mount_point: "{{ openbao_intermediate_ca_name }}"
20+
role: "{{ overcloud_openbao_pki_default_role_name }}"
21+
common_name: "{{ inventory_hostname }}"
22+
extra_params:
23+
ip_sans: "{{ admin_oc_net_name | net_ip(inventory_hostname=groups['seed'][0]) }}"
24+
register: pulp_certificate
25+
26+
- name: Ensure pulp certificates directory exists
27+
ansible.builtin.file:
28+
path: "{{ kayobe_env_config_path }}/pulp/certificates"
29+
state: directory
30+
delegate_to: localhost
31+
32+
- name: Write certificate to file
33+
no_log: true
34+
ansible.builtin.copy:
35+
dest: "{{ kayobe_env_config_path }}/pulp/certificates/pulp.crt"
36+
content: |
37+
{{ pulp_certificate.data.certificate }}
38+
{{ pulp_certificate.data.issuing_ca }}
39+
mode: "0600"
40+
delegate_to: localhost
41+
42+
- name: Write key to file
43+
no_log: true
44+
ansible.builtin.copy:
45+
dest: "{{ kayobe_env_config_path }}/pulp/certificates/pulp.key"
46+
content: |
47+
{{ pulp_certificate.data.private_key }}
48+
mode: "0600"
49+
delegate_to: localhost

etc/kayobe/container-engine.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ docker_registry: "{{ stackhpc_docker_registry }}"
4040
docker_registry_insecure: "{{ 'https' not in stackhpc_repo_mirror_url }}"
4141

4242
# CA of docker registry
43-
#docker_registry_ca:
43+
docker_registry_ca: "{{ kayobe_env_config_path ~ '/openbao/OS-TLS-INT.crt' if pulp_enable_tls | bool else none }}"
4444

4545
# List of Docker registry mirrors.
4646
#docker_registry_mirrors:

etc/kayobe/pulp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pulp_port: "{{ '443' if pulp_enable_tls | bool else '80' }}"
1414
pulp_enable_tls: false
1515

1616
# Path to a TLS certificate to use when TLS is enabled.
17-
#pulp_cert_path:
17+
pulp_cert_path: "{{ kayobe_env_config_path ~ '/pulp/certificates/pulp.crt' if pulp_enable_tls | bool else '' }}"
1818

1919
# Path to a TLS key to use when TLS is enabled.
20-
#pulp_key_path:
20+
pulp_key_path: "{{ kayobe_env_config_path ~ '/pulp/certificates/pulp.key' if pulp_enable_tls | bool else '' }}"
2121

2222
###############################################################################
2323
# Local Pulp access credentials
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
Add playbooks and configuration to enable the easy deployment of Pulp with
5+
TLS support.

0 commit comments

Comments
 (0)