Add TLS support to senlin backends

By overriding the variable `senlin_backend_ssl: True` HTTPS will
be enabled, disabling HTTP support on the senlin 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: I7e0910f163560ce7b06c51264edc05ba43131522
This commit is contained in:
Damian Dabrowski 2023-04-15 00:04:45 +02:00
parent e89e2d4662
commit 0f9a042d59
3 changed files with 73 additions and 0 deletions

View File

@ -229,6 +229,7 @@ senlin_services:
uwsgi_overrides: "{{ senlin_api_uwsgi_ini_overrides }}"
uwsgi_port: "{{ senlin_service_port }}"
uwsgi_bind_address: "{{ senlin_api_uwsgi_bind_address }}"
uwsgi_tls: "{{ senlin_backend_ssl | ternary(senlin_uwsgi_tls, {}) }}"
senlin-engine:
group: senlin_engine
service_name: senlin-engine
@ -263,6 +264,9 @@ senlin_wsgi_processes: "{{ [[ansible_facts['processor_vcpus']|default(1), 1] | m
senlin_wsgi_threads: 1
senlin_api_uwsgi_bind_address: "{{ openstack_service_bind_address | default('0.0.0.0') }}"
#senlin_api_cfn_uwsgi_bind_address: "{{ openstack_service_bind_address | default('0.0.0.0') }}"
senlin_uwsgi_tls:
crt: "{{ senlin_ssl_cert }}"
key: "{{ senlin_ssl_key }}"
senlin_role_project_group: senlin_all
@ -273,3 +277,51 @@ senlin_default_yaml_overrides: {}
senlin_aws_cloudwatch_alarm_yaml_overrides: {}
senlin_aws_rds_dbinstance_yaml_overrides: {}
senlin_policy_overrides: {}
###
### Backend TLS
###
# Define if communication between haproxy and service backends should be
# encrypted with TLS.
senlin_backend_ssl: "{{ openstack_service_backend_ssl | default(False) }}"
# Storage location for SSL certificate authority
senlin_pki_dir: "{{ openstack_pki_dir | default('/etc/openstack_deploy/pki') }}"
# Delegated host for operating the certificate authority
senlin_pki_setup_host: "{{ openstack_pki_setup_host | default('localhost') }}"
# senlin server certificate
senlin_pki_keys_path: "{{ senlin_pki_dir ~ '/certs/private/' }}"
senlin_pki_certs_path: "{{ senlin_pki_dir ~ '/certs/certs/' }}"
senlin_pki_intermediate_cert_name: "{{ openstack_pki_service_intermediate_cert_name | default('ExampleCorpIntermediate') }}"
senlin_pki_regen_cert: ''
senlin_pki_san: "{{ openstack_pki_san | default('DNS:' ~ ansible_facts['hostname'] ~ ',IP:' ~ management_address) }}"
senlin_pki_certificates:
- name: "senlin_{{ ansible_facts['hostname'] }}"
provider: ownca
cn: "{{ ansible_facts['hostname'] }}"
san: "{{ senlin_pki_san }}"
signed_by: "{{ senlin_pki_intermediate_cert_name }}"
# senlin destination files for SSL certificates
senlin_ssl_cert: /etc/senlin/senlin.pem
senlin_ssl_key: /etc/senlin/senlin.key
# Installation details for SSL certificates
senlin_pki_install_certificates:
- src: "{{ senlin_user_ssl_cert | default(senlin_pki_certs_path ~ 'senlin_' ~ ansible_facts['hostname'] ~ '-chain.crt') }}"
dest: "{{ senlin_ssl_cert }}"
owner: "{{ senlin_system_user_name }}"
group: "{{ senlin_system_user_name }}"
mode: "0644"
- src: "{{ senlin_user_ssl_key | default(senlin_pki_keys_path ~ 'senlin_' ~ ansible_facts['hostname'] ~ '.key.pem') }}"
dest: "{{ senlin_ssl_key }}"
owner: "{{ senlin_system_user_name }}"
group: "{{ senlin_system_user_name }}"
mode: "0600"
# Define user-provided SSL certificates
#senlin_user_ssl_cert: <path to cert on ansible deployment host>
#senlin_user_ssl_key: <path to cert on ansible deployment host>

View File

@ -23,3 +23,4 @@
listen:
- "venv changed"
- "systemd service changed"
- "cert installed"

View File

@ -102,6 +102,26 @@
tags:
- senlin-install
- name: Create and install SSL certificates
include_role:
name: pki
tasks_from: main_certs.yml
apply:
tags:
- senlin-config
- pki
vars:
pki_setup_host: "{{ senlin_pki_setup_host }}"
pki_dir: "{{ senlin_pki_dir }}"
pki_create_certificates: "{{ senlin_user_ssl_cert is not defined and senlin_user_ssl_key is not defined }}"
pki_regen_cert: "{{ senlin_pki_regen_cert }}"
pki_certificates: "{{ senlin_pki_certificates }}"
pki_install_certificates: "{{ senlin_pki_install_certificates }}"
when:
- senlin_backend_ssl
tags:
- always
- import_tasks: senlin_post_install.yml
tags:
- senlin-config