Start using uWSGI role

Move service to use uWSGI role instead of iternal task for uwsgi
deployment. This aims to ease the maintenance of uWSGI and speedup
metal deployments as the same uwsgi environment will be used
across all services.

Change-Id: If539762d5de0730ce97d8f8aaefb4c096d850902
This commit is contained in:
Dmitriy Rabotyagov 2019-09-04 17:55:26 +03:00
parent 288634ce0b
commit 83d643947f
11 changed files with 38 additions and 82 deletions

View File

@ -212,7 +212,6 @@ heat_pip_packages:
- python-swiftclient
- python-troveclient
- systemd-python
- uwsgi
# Specific pip packages provided by the user
heat_user_pip_packages: []
@ -231,29 +230,25 @@ heat_services:
service_name: heat-api
init_config_overrides: "{{ heat_api_init_overrides }}"
start_order: 2
wsgi_overrides: "{{ heat_api_uwsgi_ini_overrides }}"
wsgi_app: True
wsgi_name: heat-wsgi-api
uwsgi_overrides: "{{ heat_api_uwsgi_ini_overrides }}"
uwsgi_port: "{{ heat_service_port }}"
uwsgi_bind_address: "{{ heat_api_uwsgi_bind_address }}"
execstarts: "{{ heat_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/heat-api.ini"
execreloads: "{{ heat_uwsgi_bin }}/uwsgi --reload /var/run/heat-api/heat-api.pid"
heat-api-cfn:
group: heat_api_cfn
service_name: heat-api-cfn
init_config_overrides: "{{ heat_api_cfn_init_overrides }}"
start_order: 3
wsgi_overrides: "{{ heat_api_cfn_uwsgi_ini_overrides }}"
wsgi_app: True
wsgi_name: heat-wsgi-api-cfn
uwsgi_overrides: "{{ heat_api_cfn_uwsgi_ini_overrides }}"
uwsgi_port: "{{ heat_cfn_service_port }}"
uwsgi_bind_address: "{{ heat_api_cfn_uwsgi_bind_address }}"
execstarts: "{{ heat_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/heat-api-cfn.ini"
execreloads: "{{ heat_uwsgi_bin }}/uwsgi --reload /var/run/heat-api-cfn/heat-api-cfn.pid"
heat-engine:
group: heat_engine
service_name: heat-engine
execstarts: "{{ heat_uwsgi_bin }}/heat-engine"
execstarts: "{{ heat_bin }}/heat-engine"
init_config_overrides: "{{ heat_engine_init_overrides }}"
start_order: 1
@ -273,7 +268,6 @@ heat_api_cfn_uwsgi_ini_overrides: {}
heat_wsgi_processes_max: 16
heat_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, heat_wsgi_processes_max] | min }}"
heat_wsgi_threads: 1
heat_wsgi_buffer_size: 65535
heat_api_uwsgi_bind_address: 0.0.0.0
heat_api_cfn_uwsgi_bind_address: 0.0.0.0

View File

@ -67,6 +67,7 @@
- item.condition | bool
with_items: "{{ heat_core_files }}"
notify:
- Restart uwsgi services
- Restart heat services
- name: Cleanup fetched temp files

View File

@ -1,32 +0,0 @@
---
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Ensure uWSGI directory exists
file:
path: "/etc/uwsgi/"
state: directory
mode: "0711"
- name: Apply uWSGI configuration
config_template:
src: "heat-uwsgi.ini.j2"
dest: "/etc/uwsgi/{{ item.service_name }}.ini"
mode: "0744"
config_overrides: "{{ item.wsgi_overrides }}"
config_type: ini
with_items: "{{ filtered_heat_services }}"
when: item.wsgi_app | default(False)
notify:
- Restart heat services

View File

@ -117,9 +117,15 @@
tags:
- heat-config
- import_tasks: heat_uwsgi.yml
- name: Import uwsgi role
import_role:
name: uwsgi
vars:
uwsgi_services: "{{ heat_uwsgi_services }}"
uwsgi_install_method: "{{ heat_install_method }}"
tags:
- heat-config
- uwsgi
- import_tasks: heat_service_setup.yml
when:

View File

@ -1,27 +0,0 @@
[uwsgi]
uid = {{ heat_system_user_name }}
gid = {{ heat_system_group_name }}
{% if heat_install_method == 'source' %}
virtualenv = /openstack/venvs/heat-{{ heat_venv_tag }}
{% endif %}
{% if heat_install_method == 'distro' and (ansible_os_family | lower) == 'debian' %}
plugin = python3
{% endif %}
wsgi-file = {{ heat_bin }}/{{ item.wsgi_name }}
http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }}
master = true
enable-threads = true
processes = {{ heat_wsgi_processes }}
threads = {{ heat_wsgi_threads }}
exit-on-reload = true
die-on-term = true
lazy-apps = true
add-header = Connection: close
buffer-size = {{ heat_wsgi_buffer_size }}
thunder-lock = true
disable-logging = true
# Avoid filling up the logs with health check requests from haproxy.
route-user-agent = ^osa-haproxy-healthcheck$ donotlog:

View File

@ -51,3 +51,7 @@
src: https://opendev.org/openstack/ansible-role-python_venv_build
scm: git
version: master
- name: uwsgi
src: https://opendev.org/openstack/ansible-role-uwsgi
scm: git
version: master

View File

@ -27,11 +27,7 @@ heat_devel_distro_packages:
heat_service_distro_packages:
- python3-heat
- python3-systemd
- uwsgi
- uwsgi-plugin-python3
heat_oslomsg_amqp1_distro_packages:
- libsasl2-modules
- sasl2-bin
heat_uwsgi_bin: '/usr/bin'

View File

@ -23,7 +23,8 @@ filtered_heat_services: |-
{% for key, value in heat_services.items() %}
{% if (value['group'] in group_names) and
(('condition' not in value) or
('condition' in value and value['condition'])) %}
('condition' in value and value['condition'])) and
not ('wsgi_app' in value and value['wsgi_app']) %}
{% set _ = value.update(
{
'service_key': key,
@ -39,6 +40,27 @@ filtered_heat_services: |-
{% endfor %}
{{ services | sort(attribute='start_order') }}
heat_uwsgi_services: |-
{% set services = {} %}
{% for key, value in heat_services.items() %}
{% if (value['group'] in group_names) and
(('condition' not in value) or ('condition' in value and value['condition']))
and ('wsgi_app' in value and value['wsgi_app']) %}
{% set _ = value.update(
{
'wsgi_path': heat_bin ~ '/' ~ value.wsgi_name,
'wsgi_venv': ((heat_install_method == 'source') | ternary(heat_bin | dirname, None)),
'uwsgi_uid': heat_system_user_name,
'uwsgi_guid': heat_system_group_name,
'uwsgi_processes': heat_wsgi_processes,
'uwsgi_threads': heat_wsgi_threads
}
) %}
{% set _ = services.update({key: value}) %}
{% endif %}
{% endfor %}
{{ services }}
heat_core_files:
- tmp_f: "/tmp/api-paste.ini"
target_f: "{{ (heat_install_method == 'distro' and ansible_os_family == 'RedHat') | ternary('/usr/share/heat', '/etc/heat') }}/api-paste.ini"

View File

@ -29,12 +29,8 @@ heat_service_distro_packages:
- openstack-heat-engine
- openstack-heat-ui
- systemd-python
- uwsgi
- uwsgi-plugin-python
heat_oslomsg_amqp1_distro_packages:
- cyrus-sasl-lib
- cyrus-sasl-plain
- cyrus-sasl-md5
heat_uwsgi_bin: '/usr/sbin'

View File

@ -21,4 +21,3 @@ heat_package_list: |-
{{ packages }}
_heat_bin: "/openstack/venvs/heat-{{ heat_venv_tag }}/bin"
heat_uwsgi_bin: "{{ _heat_bin }}"

View File

@ -28,11 +28,8 @@ heat_service_distro_packages:
- openstack-heat-engine
- openstack-heat-templates
- python-systemd
- uwsgi-python
heat_oslomsg_amqp1_distro_packages:
- cyrus-sasl
- cyrus-sasl-plain
- cyrus-sasl-digestmd5
heat_uwsgi_bin: '/usr/sbin'