From ac93b1f46fc2304efeade2183c394cd008c8333f Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 5 Sep 2019 14:46:14 +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: Ia1788a7a9ce80349440bedbb2a0fdeb2a7f9934a --- defaults/main.yml | 7 ++----- tasks/main.yml | 10 ++++++++++ tasks/mistral_install.yml | 19 ------------------- tasks/mistral_post_install.yml | 1 + templates/mistral-uwsgi.ini.j2 | 29 ----------------------------- tests/ansible-role-requirements.yml | 4 ++++ vars/debian.yml | 3 --- vars/main.yml | 26 ++++++++++++++++++++++++-- vars/redhat-7.yml | 2 -- vars/source_install.yml | 1 - vars/suse.yml | 2 -- 11 files changed, 41 insertions(+), 63 deletions(-) delete mode 100644 templates/mistral-uwsgi.ini.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 68a01f7..ec8c1ee 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -44,7 +44,7 @@ mistral_pip_packages: - PyMySQL - python-memcached - systemd-python - - uwsgi + mistral_optional_oslomsg_amqp1_pip_packages: - oslo.messaging[amqp1] mistral_venv_tag: "{{ venv_tag | default('untagged') }}" @@ -77,18 +77,15 @@ mistral_services: service_name: mistral-api init_config_overrides: "{{ mistral_api_init_overrides }}" start_order: 2 - wsgi_overrides: "{{ mistral_api_uwsgi_ini_overrides }}" wsgi_app: true wsgi_name: mistral-wsgi-api + uwsgi_overrides: "{{ mistral_api_uwsgi_ini_overrides }}" uwsgi_bind_address: "{{ mistral_bind_address }}" uwsgi_port: "{{ mistral_service_port }}" - execstarts: "{{ mistral_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/mistral-api.ini" - execreloads: "{{ mistral_uwsgi_bin }}/uwsgi --reload /var/run/mistral-api/mistral-api.pid" # UWSGI settings mistral_wsgi_processes_max: 16 mistral_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, mistral_wsgi_processes_max] | min }}" -mistral_wsgi_buffer_size: 65535 mistral_wsgi_threads: 1 # RPC diff --git a/tasks/main.yml b/tasks/main.yml index 059fd1f..9ce857e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -122,6 +122,16 @@ - mistral-config - systemd-service +- name: Import uwsgi role + import_role: + name: uwsgi + vars: + uwsgi_services: "{{ uwsgi_mistral_services }}" + uwsgi_install_method: "{{ mistral_install_method }}" + tags: + - mistral-config + - uwsgi + - import_tasks: service_setup.yml vars: _service_adminuri_insecure: "{{ keystone_service_adminuri_insecure }}" diff --git a/tasks/mistral_install.yml b/tasks/mistral_install.yml index b920ec5..8bde2cf 100644 --- a/tasks/mistral_install.yml +++ b/tasks/mistral_install.yml @@ -94,22 +94,3 @@ value: true when: (install_packages is changed) or ('need_service_restart' not in ansible_local['openstack_ansible']['mistral']) - -- name: Ensure uWSGI directory exists - file: - path: "/etc/uwsgi/" - state: directory - mode: "0711" - -- name: Apply uWSGI configuration - config_template: - src: "mistral-uwsgi.ini.j2" - dest: "/etc/uwsgi/{{ item.service_name }}.ini" - mode: "0744" - config_overrides: "{{ item.wsgi_overrides }}" - config_type: ini - with_items: "{{ filtered_mistral_services }}" - when: item.wsgi_app | default(False) - notify: - - Manage LB - - Restart mistral services diff --git a/tasks/mistral_post_install.yml b/tasks/mistral_post_install.yml index 9d1145f..cd4c00c 100644 --- a/tasks/mistral_post_install.yml +++ b/tasks/mistral_post_install.yml @@ -30,6 +30,7 @@ notify: - Manage LB - Restart mistral services + - Restart uwsgi services - name: Implement policy.json if there are overrides configured copy: diff --git a/templates/mistral-uwsgi.ini.j2 b/templates/mistral-uwsgi.ini.j2 deleted file mode 100644 index 4781cc8..0000000 --- a/templates/mistral-uwsgi.ini.j2 +++ /dev/null @@ -1,29 +0,0 @@ -# {{ ansible_managed }} -[uwsgi] -uid = {{ mistral_system_user_name }} -gid = {{ mistral_system_group_name }} - -{% if mistral_install_method == 'source' %} -virtualenv = /openstack/venvs/mistral-{{ mistral_venv_tag }} -{% endif %} -{% if mistral_install_method == 'distro' and (ansible_os_family | lower) == 'debian' %} -plugin = python3 -{% endif %} -wsgi-file = {{ mistral_bin }}/{{ item.wsgi_name }} -http = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} - -master = true -enable-threads = true -processes = {{ mistral_wsgi_processes }} -threads = {{ mistral_wsgi_threads }} -exit-on-reload = false -die-on-term = true -lazy-apps = true -add-header = Connection: close -buffer-size = {{ mistral_wsgi_buffer_size }} -thunder-lock = true -disable-logging = true -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 b061b9d..bbbc6bb 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -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 diff --git a/vars/debian.yml b/vars/debian.yml index 5c0c52d..259fd21 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -24,12 +24,9 @@ mistral_distro_packages: mistral_service_distro_packages: - python3-mistral - python3-systemd - - uwsgi - - uwsgi-plugin-python3 mistral_oslomsg_amqp1_distro_packages: - libsasl2-modules - sasl2-bin -mistral_uwsgi_bin: '/usr/bin' cache_timeout: 600 diff --git a/vars/main.yml b/vars/main.yml index abbccf3..cb1ce9a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -23,9 +23,31 @@ filtered_mistral_services: |- {% for key, value in mistral_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') }} \ No newline at end of file + {{ services | sort(attribute='start_order') }} + +uwsgi_mistral_services: |- + {% set services = {} %} + {% for key, value in mistral_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': mistral_bin ~ '/' ~ value.wsgi_name, + 'wsgi_venv': ((mistral_install_method == 'source') | ternary(mistral_bin | dirname, None)), + 'uwsgi_uid': mistral_system_user_name, + 'uwsgi_guid': mistral_system_group_name, + 'uwsgi_processes': mistral_wsgi_processes, + 'uwsgi_threads': mistral_wsgi_threads + } + ) %} + {% set _ = services.update({key: value}) %} + {% endif %} + {% endfor %} + {{ services }} diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 2e18a44..e8fd366 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -30,5 +30,3 @@ mistral_oslomsg_amqp1_distro_packages: - cyrus-sasl-lib - cyrus-sasl-plain - cyrus-sasl-md5 - -mistral_uwsgi_bin: '/usr/sbin' \ No newline at end of file diff --git a/vars/source_install.yml b/vars/source_install.yml index 1e46b62..3a94651 100644 --- a/vars/source_install.yml +++ b/vars/source_install.yml @@ -21,4 +21,3 @@ mistral_package_list: |- {{ packages }} _mistral_bin: "/openstack/venvs/mistral-{{ mistral_venv_tag }}/bin" -mistral_uwsgi_bin: "{{ _mistral_bin }}" \ No newline at end of file diff --git a/vars/suse.yml b/vars/suse.yml index 2c0612f..4ff14f1 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -27,5 +27,3 @@ mistral_oslomsg_amqp1_distro_packages: - cyrus-sasl - cyrus-sasl-plain - cyrus-sasl-digestmd5 - -mistral_uwsgi_bin: '/usr/sbin' \ No newline at end of file