From 39dcdeedc8242693a0c75029f62b88fe3029d313 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 4 Sep 2019 19:24:35 +0300 Subject: [PATCH] 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: Ie79a7ba7d62504e9e81edbb386f8e52ce0a03074 --- defaults/main.yml | 6 +--- tasks/ironic_pre_install.yml | 2 -- tasks/ironic_uwsgi.yml | 44 ---------------------------- tasks/main.yml | 8 ++++- templates/ironic-uwsgi.ini.j2 | 22 -------------- templates/ironic-wsgi.py.j2 | 45 ----------------------------- tests/ansible-role-requirements.yml | 4 +++ vars/main.yml | 24 ++++++++++++++- 8 files changed, 35 insertions(+), 120 deletions(-) delete mode 100644 tasks/ironic_uwsgi.yml delete mode 100644 templates/ironic-uwsgi.ini.j2 delete mode 100644 templates/ironic-wsgi.py.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 290d9c22..6808c23b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -60,13 +60,11 @@ ironic_services: group: ironic_api service_name: ironic-api init_config_overrides: "{{ ironic_api_init_config_overrides }}" - wsgi_overrides: "{{ ironic_api_uwsgi_ini_overrides }}" wsgi_app: True - log_string: "--logto " wsgi_name: ironic-api-wsgi + uwsgi_overrides: "{{ ironic_api_uwsgi_ini_overrides }}" uwsgi_port: "{{ ironic_service_port }}" uwsgi_bind_address: "{{ ironic_uwsgi_bind_address }}" - execstarts: "{{ ironic_bin }}/uwsgi --ini /etc/uwsgi/ironic-api.ini" ironic-conductor: group: ironic_conductor service_name: ironic-conductor @@ -195,7 +193,6 @@ ironic_pip_packages: - sushy - systemd-python - UcsSdk - - uwsgi ## Oslo Messaging Info # RPC @@ -233,7 +230,6 @@ ironic_service_user_name: "ironic" ironic_wsgi_threads: 1 ironic_wsgi_processes_max: 16 ironic_wsgi_processes: "{{ [[ansible_processor_vcpus|default(4) // 4, 1] | max, ironic_wsgi_processes_max] | min }}" -ironic_wsgi_buffer_size: 65535 ironic_uwsgi_bind_address: 0.0.0.0 ### OpenStack Services to integrate with diff --git a/tasks/ironic_pre_install.yml b/tasks/ironic_pre_install.yml index 1d18e9e5..6b32cf9b 100644 --- a/tasks/ironic_pre_install.yml +++ b/tasks/ironic_pre_install.yml @@ -60,5 +60,3 @@ - { path: "{{ ironic_system_home_folder }}/cache/api", mode: "0700" } - { path: "{{ ironic_lock_path }}" } - { path: "/var/run/ironic" } - - { path: "/var/www/cgi-bin", owner: root, group: root } - - { path: "/var/www/cgi-bin/ironic" } diff --git a/tasks/ironic_uwsgi.yml b/tasks/ironic_uwsgi.yml deleted file mode 100644 index 33ed1fc7..00000000 --- a/tasks/ironic_uwsgi.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -# Copyright 2014, 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: Setup Ironic WSGI Configs - template: - src: "ironic-wsgi.py.j2" - dest: "{{ ironic_bin }}/{{ item.wsgi_name }}.wsgi" - owner: "{{ ironic_system_user_name }}" - group: "{{ ironic_system_group_name }}" - mode: "0755" - with_list: "{{ filtered_ironic_services }}" - when: item.wsgi_app | default(False) - notify: - - Restart ironic services - -- name: Ensure uWSGI directory exists - file: - path: "/etc/uwsgi/" - state: directory - mode: "0711" - -- name: Apply uWSGI configuration - config_template: - src: "ironic-uwsgi.ini.j2" - dest: "/etc/uwsgi/{{ item.service_name }}.ini" - mode: "0744" - config_overrides: "{{ item.wsgi_overrides }}" - config_type: ini - with_list: "{{ filtered_ironic_services }}" - when: item.wsgi_app | default(False) - notify: - - Restart ironic services diff --git a/tasks/main.yml b/tasks/main.yml index 5938bfe7..906cf11a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -83,9 +83,15 @@ tags: - ironic-config -- import_tasks: ironic_uwsgi.yml +- name: Import uwsgi role + import_role: + name: uwsgi + vars: + uwsgi_services: "{{ uwsgi_ironic_services }}" + uwsgi_install_method: "source" tags: - ironic-config + - uwsgi - import_tasks: ironic_conductor_post_install.yml when: "ironic_services['ironic-conductor']['group'] in group_names" diff --git a/templates/ironic-uwsgi.ini.j2 b/templates/ironic-uwsgi.ini.j2 deleted file mode 100644 index 7c397e39..00000000 --- a/templates/ironic-uwsgi.ini.j2 +++ /dev/null @@ -1,22 +0,0 @@ -[uwsgi] -uid = {{ ironic_system_user_name }} -gid = {{ ironic_system_group_name }} - -virtualenv = /openstack/venvs/ironic-{{ ironic_venv_tag }} -wsgi-file = {{ ironic_bin }}/{{ item.wsgi_name }}.wsgi -http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} - -master = true -enable-threads = true -processes = {{ ironic_wsgi_processes }} -threads = {{ ironic_wsgi_threads }} -exit-on-reload = true -die-on-term = true -lazy-apps = true -add-header = Connection: close -buffer-size = {{ ironic_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: diff --git a/templates/ironic-wsgi.py.j2 b/templates/ironic-wsgi.py.j2 deleted file mode 100644 index 08e607de..00000000 --- a/templates/ironic-wsgi.py.j2 +++ /dev/null @@ -1,45 +0,0 @@ -# -*- mode: python -*- -# -*- encoding: utf-8 -*- -# -# 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. -#""" -#Use this file for deploying the API service under Apache2 mod_wsgi. -#""" - -import os - -activate_this = os.path.expanduser("{{ ironic_bin }}/activate_this.py") -execfile(activate_this, dict(__file__=activate_this)) - -import logging -import sys - -from oslo_config import cfg -import oslo_i18n as i18n -from oslo_log import log - -from ironic.api import app -from ironic.common import service - - -CONF = cfg.CONF - -i18n.install('ironic') - -service.prepare_service(sys.argv) - -LOG = log.getLogger(__name__) -LOG.debug("Configuration:") -CONF.log_opt_values(LOG, logging.DEBUG) - -application = app.VersionSelectorApplication() diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index da208038..7ae32544 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -83,3 +83,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 diff --git a/vars/main.yml b/vars/main.yml index 21766c04..84992350 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -155,7 +155,8 @@ filtered_ironic_services: |- {% for key, value in ironic_services.items() %} {% if (value['group'] in group_names) and (('service_en' not in value) or - ('service_en' in value and value['service_en'])) %} + ('service_en' in value and value['service_en'])) and + not ('wsgi_app' in value and value['wsgi_app']) %} {% set _ = value.update( { 'service_key': key, @@ -176,6 +177,27 @@ filtered_ironic_services: |- {% endfor %} {{ services }} +uwsgi_ironic_services: |- + {% set services = {} %} + {% for key, value in ironic_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': ironic_bin ~ '/' ~ value.wsgi_name, + 'wsgi_venv': ironic_bin | dirname, + 'uwsgi_uid': ironic_system_user_name, + 'uwsgi_guid': ironic_system_group_name, + 'uwsgi_processes': ironic_wsgi_processes, + 'uwsgi_threads': ironic_wsgi_threads + } + ) %} + {% set _ = services.update({key: value}) %} + {% endif %} + {% endfor %} + {{ services }} + filtered_ironic_drivers: |- {% set concat_drivers = [] %} {% for driver in ironic_drivers_enabled %}