Add TLS support to trove backends

By overriding the variable `trove_backend_ssl: True` HTTPS will
be enabled, disabling HTTP support on the trove backend api.

The ansible-role-pki is used to generate the required TLS
certificates if this functionality is enabled.

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/879085
Change-Id: I15223354a28f0cc6c203f0cb3a19b9af834d4158
This commit is contained in:
Damian Dabrowski 2023-04-14 23:03:37 +02:00
parent 62977e30f6
commit 2d1f4b405b
3 changed files with 73 additions and 0 deletions

View File

@ -72,6 +72,9 @@ trove_api_workers: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['proce
# uWSGI settings # uWSGI settings
trove_wsgi_threads: 1 trove_wsgi_threads: 1
trove_use_uwsgi: True trove_use_uwsgi: True
trove_uwsgi_tls:
crt: "{{ trove_ssl_cert }}"
key: "{{ trove_ssl_key }}"
## Cap the maximum number of threads / workers when a user value is unspecified. ## Cap the maximum number of threads / workers when a user value is unspecified.
trove_conductor_workers_max: 16 trove_conductor_workers_max: 16
@ -280,6 +283,7 @@ trove_services:
uwsgi_overrides: "{{ trove_api_uwsgi_ini_overrides }}" uwsgi_overrides: "{{ trove_api_uwsgi_ini_overrides }}"
uwsgi_bind_address: "{{ trove_service_host }}" uwsgi_bind_address: "{{ trove_service_host }}"
uwsgi_port: "{{ trove_service_port }}" uwsgi_port: "{{ trove_service_port }}"
uwsgi_tls: "{{ trove_backend_ssl | ternary(trove_uwsgi_tls, {}) }}"
start_order: 1 start_order: 1
trove-conductor: trove-conductor:
group: trove_conductor group: trove_conductor
@ -293,3 +297,51 @@ trove_services:
execstarts: "{{ trove_bin }}/trove-taskmanager" execstarts: "{{ trove_bin }}/trove-taskmanager"
init_config_overrides: "{{ trove_taskmanager_init_config_overrides }}" init_config_overrides: "{{ trove_taskmanager_init_config_overrides }}"
start_order: 3 start_order: 3
###
### Backend TLS
###
# Define if communication between haproxy and service backends should be
# encrypted with TLS.
trove_backend_ssl: "{{ openstack_service_backend_ssl | default(False) }}"
# Storage location for SSL certificate authority
trove_pki_dir: "{{ openstack_pki_dir | default('/etc/openstack_deploy/pki') }}"
# Delegated host for operating the certificate authority
trove_pki_setup_host: "{{ openstack_pki_setup_host | default('localhost') }}"
# trove server certificate
trove_pki_keys_path: "{{ trove_pki_dir ~ '/certs/private/' }}"
trove_pki_certs_path: "{{ trove_pki_dir ~ '/certs/certs/' }}"
trove_pki_intermediate_cert_name: "{{ openstack_pki_service_intermediate_cert_name | default('ExampleCorpIntermediate') }}"
trove_pki_regen_cert: ''
trove_pki_san: "{{ openstack_pki_san | default('DNS:' ~ ansible_facts['hostname'] ~ ',IP:' ~ management_address) }}"
trove_pki_certificates:
- name: "trove_{{ ansible_facts['hostname'] }}"
provider: ownca
cn: "{{ ansible_facts['hostname'] }}"
san: "{{ trove_pki_san }}"
signed_by: "{{ trove_pki_intermediate_cert_name }}"
# trove destination files for SSL certificates
trove_ssl_cert: /etc/trove/trove.pem
trove_ssl_key: /etc/trove/trove.key
# Installation details for SSL certificates
trove_pki_install_certificates:
- src: "{{ trove_user_ssl_cert | default(trove_pki_certs_path ~ 'trove_' ~ ansible_facts['hostname'] ~ '-chain.crt') }}"
dest: "{{ trove_ssl_cert }}"
owner: "{{ trove_system_user_name }}"
group: "{{ trove_system_user_name }}"
mode: "0644"
- src: "{{ trove_user_ssl_key | default(trove_pki_keys_path ~ 'trove_' ~ ansible_facts['hostname'] ~ '.key.pem') }}"
dest: "{{ trove_ssl_key }}"
owner: "{{ trove_system_user_name }}"
group: "{{ trove_system_user_name }}"
mode: "0600"
# Define user-provided SSL certificates
#trove_user_ssl_cert: <path to cert on ansible deployment host>
#trove_user_ssl_key: <path to cert on ansible deployment host>

View File

@ -31,3 +31,4 @@
- "Restart trove services" - "Restart trove services"
- "venv changed" - "venv changed"
- "systemd service changed" - "systemd service changed"
- "cert installed"

View File

@ -87,6 +87,26 @@
tags: tags:
- trove-install - trove-install
- name: Create and install SSL certificates
include_role:
name: pki
tasks_from: main_certs.yml
apply:
tags:
- trove-config
- pki
vars:
pki_setup_host: "{{ trove_pki_setup_host }}"
pki_dir: "{{ trove_pki_dir }}"
pki_create_certificates: "{{ trove_user_ssl_cert is not defined and trove_user_ssl_key is not defined }}"
pki_regen_cert: "{{ trove_pki_regen_cert }}"
pki_certificates: "{{ trove_pki_certificates }}"
pki_install_certificates: "{{ trove_pki_install_certificates }}"
when:
- trove_backend_ssl
tags:
- always
- name: Install the python venv - name: Install the python venv
import_role: import_role:
name: "python_venv_build" name: "python_venv_build"