Skip to content

Commit 2b89e64

Browse files
mnasiadkaAlex-Welsh
authored andcommitted
magnum: Switch to use uWSGI and add support for backend TLS
Change-Id: I0a7f27fb3a6239890aa1b4d8d1a149113d8ee203 Signed-off-by: Michal Nasiadka <[email protected]> Signed-off-by: Bartosz Bezak <[email protected]>
1 parent f6ff824 commit 2b89e64

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

ansible/roles/magnum/defaults/main.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ magnum_services:
1010
volumes: "{{ magnum_api_default_volumes + magnum_api_extra_volumes }}"
1111
dimensions: "{{ magnum_api_dimensions }}"
1212
healthcheck: "{{ magnum_api_healthcheck }}"
13+
wsgi: "magnum.wsgi.api:application"
1314
haproxy:
1415
magnum_api:
1516
enabled: "{{ enable_magnum }}"
@@ -19,6 +20,7 @@ magnum_services:
1920
listen_port: "{{ magnum_api_listen_port }}"
2021
backend_http_extra:
2122
- "option httpchk"
23+
tls_backend: "{{ magnum_enable_tls_backend | bool }}"
2224
magnum_api_external:
2325
enabled: "{{ enable_magnum }}"
2426
mode: "http"
@@ -28,6 +30,7 @@ magnum_services:
2830
listen_port: "{{ magnum_api_listen_port }}"
2931
backend_http_extra:
3032
- "option httpchk"
33+
tls_backend: "{{ magnum_enable_tls_backend | bool }}"
3134
magnum-conductor:
3235
container_name: magnum_conductor
3336
group: magnum-conductor
@@ -98,7 +101,7 @@ magnum_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
98101
magnum_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
99102
magnum_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
100103
magnum_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
101-
magnum_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ magnum_api_port }}"]
104+
magnum_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl {{ 'https' if magnum_enable_tls_backend | bool else 'http' }}://{{ api_interface_address | put_address_in_context('url') }}:{{ magnum_api_listen_port }}"]
102105
magnum_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
103106
magnum_api_healthcheck:
104107
interval: "{{ magnum_api_healthcheck_interval }}"
@@ -195,10 +198,17 @@ magnum_ks_users:
195198
password: "{{ magnum_keystone_password }}"
196199
role: "admin"
197200

201+
###################
198202
# Database
203+
###################
199204
magnum_database_enable_tls_internal: "{{ database_enable_tls_internal | bool }}"
200205

201206
###################
202207
# Copy certificates
203208
###################
204-
magnum_copy_certs: "{{ kolla_copy_ca_into_containers | bool or magnum_database_enable_tls_internal | bool }}"
209+
magnum_copy_certs: "{{ kolla_copy_ca_into_containers | bool or magnum_enable_tls_backend | bool or magnum_database_enable_tls_internal | bool }}"
210+
211+
####################
212+
# TLS
213+
####################
214+
magnum_enable_tls_backend: "{{ kolla_enable_tls_backend }}"

ansible/roles/magnum/tasks/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@
6363
become: true
6464
with_dict: "{{ magnum_services | select_services_enabled_and_mapped_to_host }}"
6565

66+
- name: Configure uWSGI for Magnum
67+
include_role:
68+
name: service-uwsgi-config
69+
vars:
70+
project_services: "{{ magnum_services }}"
71+
service: "{{ magnum_services['magnum-api'] }}"
72+
service_name: "magnum-api"
73+
service_uwsgi_config_http_port: "{{ magnum_api_listen_port }}"
74+
service_uwsgi_config_log_file_chmod: "644"
75+
service_uwsgi_config_module: "{{ service.wsgi }}"
76+
service_uwsgi_config_tls_backend: "{{ magnum_enable_tls_backend | bool }}"
77+
service_uwsgi_config_tls_cert: "/etc/magnum/certs/magnum-cert.pem"
78+
service_uwsgi_config_tls_key: "/etc/magnum/certs/magnum-key.pem"
79+
service_uwsgi_config_workers: "{{ magnum_api_workers }}"
80+
service_uwsgi_config_uid: "magnum"
81+
when:
82+
- service | service_enabled_and_mapped_to_host
83+
6684
- name: Copying over magnum.conf
6785
vars:
6886
service_name: "{{ item.key }}"

ansible/roles/magnum/templates/magnum-api.json.j2

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
{
2-
"command": "magnum-api --config-file /etc/magnum/magnum.conf",
2+
"command": "uwsgi /etc/magnum/magnum-api-uwsgi.ini",
33
"config_files": [
44
{
55
"source": "{{ container_config_directory }}/magnum.conf",
66
"dest": "/etc/magnum/magnum.conf",
77
"owner": "magnum",
88
"perm": "0600"
9-
}{% if magnum_kubeconfig_file_path is defined %},
9+
},
10+
{
11+
"source": "{{ container_config_directory }}/magnum-api-uwsgi.ini",
12+
"dest": "/etc/magnum/magnum-api-uwsgi.ini",
13+
"owner": "magnum",
14+
"perm": "0600"
15+
}{% if magnum_enable_tls_backend | bool %},
16+
{
17+
"source": "{{ container_config_directory }}/magnum-cert.pem",
18+
"dest": "/etc/magnum/certs/magnum-cert.pem",
19+
"owner": "magnum",
20+
"perm": "0600"
21+
},
22+
{
23+
"source": "{{ container_config_directory }}/magnum-key.pem",
24+
"dest": "/etc/magnum/certs/magnum-key.pem",
25+
"owner": "magnum",
26+
"perm": "0600"
27+
}{% endif %}{% if magnum_kubeconfig_file_path is defined %},
1028
{
1129
"source": "{{ container_config_directory }}/kubeconfig",
1230
"dest": "/var/lib/magnum/.kube/config",

ansible/roles/magnum/templates/magnum.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
debug = {{ magnum_logging_debug }}
33
state_path = /var/lib/magnum
44
log_dir = /var/log/kolla/magnum
5+
log_file = /var/log/kolla/magnum/{{ service_name }}.log
56

67
host = {{ api_interface_address }}
78

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
upgrade:
3+
- |
4+
``magnum-api`` is now running under uWSGI and now supports backend TLS.

0 commit comments

Comments
 (0)