From abbfec221be5fbe001dce446f24d0539f375cda1 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Thu, 30 Jan 2020 09:29:01 +0100 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: I946adf21b58e117508dcc470c0fb3e9c2565c26d --- defaults/main.yml | 5 +---- tasks/main.yml | 10 ++++++++- tasks/manila_post_install.yml | 1 + tasks/manila_uwsgi.yml | 34 ----------------------------- templates/manila-uwsgi.ini.j2 | 25 --------------------- tests/ansible-role-requirements.yml | 4 ++++ vars/main.yml | 24 +++++++++++++++++++- 7 files changed, 38 insertions(+), 65 deletions(-) delete mode 100644 tasks/manila_uwsgi.yml delete mode 100644 templates/manila-uwsgi.ini.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 268e070..eee765f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -218,7 +218,6 @@ manila_pip_packages: - python-openstackclient - python-memcached - systemd-python - - uwsgi # Memcached override manila_memcached_servers: "{{ memcached_servers }}" @@ -261,11 +260,9 @@ manila_services: service_name: manila-api init_config_overrides: "{{ manila_api_init_overrides }}" start_order: 4 - execstarts: "{{ manila_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/manila-api.ini" - execreloads: "{{ manila_uwsgi_bin }}/uwsgi --reload /var/run/manila_api/manila-api.pid" - wsgi_overrides: "{{ manila_api_uwsgi_ini_overrides }}" wsgi_app: True wsgi_name: manila-wsgi + uwsgi_overrides: "{{ manila_api_uwsgi_ini_overrides }}" uwsgi_port: "{{ manila_service_port }}" uwsgi_bind_address: "{{ manila_uwsgi_bind_address }}" diff --git a/tasks/main.yml b/tasks/main.yml index 11dd4d6..41b761f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -121,9 +121,17 @@ tags: - manila-config -- import_tasks: manila_uwsgi.yml +- name: Import uwsgi role + import_role: + name: uwsgi + vars: + uwsgi_services: "{{ uwsgi_manila_services }}" + uwsgi_install_method: "source" + when: + - manila_services['manila-api']['group'] in group_names tags: - manila-config + - uwsgi - name: import_tasks ceph_client role import_role: diff --git a/tasks/manila_post_install.yml b/tasks/manila_post_install.yml index 1fbe364..f404f2a 100644 --- a/tasks/manila_post_install.yml +++ b/tasks/manila_post_install.yml @@ -36,6 +36,7 @@ notify: - Manage LB - Restart manila services + - Restart uwsgi services - name: Drop sudoers file template: diff --git a/tasks/manila_uwsgi.yml b/tasks/manila_uwsgi.yml deleted file mode 100644 index 811d17c..0000000 --- a/tasks/manila_uwsgi.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -# Copyright 2019, 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: "manila-uwsgi.ini.j2" - dest: "/etc/uwsgi/{{ item.service_name }}.ini" - mode: "0744" - config_overrides: "{{ item.wsgi_overrides }}" - config_type: ini - with_items: "{{ filtered_manila_services }}" - when: - - item.wsgi_app | default(false) - notify: - - Manage LB - - Restart manila services diff --git a/templates/manila-uwsgi.ini.j2 b/templates/manila-uwsgi.ini.j2 deleted file mode 100644 index 5923fab..0000000 --- a/templates/manila-uwsgi.ini.j2 +++ /dev/null @@ -1,25 +0,0 @@ -[uwsgi] -uid = {{ manila_system_user_name }} -gid = {{ manila_system_group_name }} - -{% if manila_install_method == 'source' %} -virtualenv = /openstack/venvs/manila-{{ manila_venv_tag }} -{% endif %} -wsgi-file = {{ manila_bin }}/{{ item.wsgi_name }} -http = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} - -master = true -enable-threads = true -processes = {{ manila_wsgi_processes }} -threads = {{ manila_wsgi_threads }} -exit-on-reload = false -die-on-term = true -lazy-apps = true -add-header = Connection: close -buffer-size = {{ manila_wsgi_buffer_size }} -thunder-lock = true -logfile-chmod = 644 -pidfile = /var/run/{{ item.service_name }}/{{ item.service_name }}.pid - -# Avoid filling up the logs with health check requests from haproxy. -route-user-agent = ^osa-haproxy-healthcheck$ donotlog: diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index bb057d7..18b8126 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -79,3 +79,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 257bc0f..e5dcf40 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -26,13 +26,35 @@ filtered_manila_services: |- {% for key, value in manila_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}) %} {% set _ = services.append(value) %} {% endif %} {% endfor %} {{ services | sort(attribute='start_order') }} +uwsgi_manila_services: |- + {% set services = {} %} + {% for key, value in manila_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': manila_bin ~ '/' ~ value.wsgi_name, + 'wsgi_venv': ((manila_install_method == 'source') | ternary(manila_bin | dirname, None)), + 'uwsgi_uid': manila_system_user_name, + 'uwsgi_guid': manila_system_group_name, + 'uwsgi_processes': manila_wsgi_processes, + 'uwsgi_threads': manila_wsgi_threads + } + ) %} + {% set _ = services.update({key: value}) %} + {% endif %} + {% endfor %} + {{ services }} + manila_core_files: - src: "manila.conf.j2" dest: "/etc/manila/manila.conf"