diff --git a/defaults/main.yml b/defaults/main.yml index 12a29d45..f7a0fdd0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -161,7 +161,6 @@ octavia_pip_packages: - octavia - shade - systemd-python - - uwsgi # Specific pip packages provided by the user octavia_user_pip_packages: [] @@ -181,14 +180,11 @@ octavia_services: service_name: octavia-api start_order: 4 init_config_overrides: "{{ octavia_api_init_overrides }}" - execstarts: "{{ octavia_uwsgi_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini" - execreloads: "{{ octavia_uwsgi_bin }}/uwsgi --reload /var/run/octavia-api/octavia-api.pid" - wsgi_overrides: "{{ octavia_api_uwsgi_ini_overrides }}" wsgi_app: True wsgi_name: octavia-wsgi + uwsgi_overrides: "{{ octavia_api_uwsgi_ini_overrides }}" uwsgi_port: "{{ octavia_service_port }}" uwsgi_bind_address: "{{ octavia_uwsgi_bind_address }}" - program_override: "{{ octavia_uwsgi_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini" octavia-worker: group: octavia-worker service_name: octavia-worker @@ -417,7 +413,6 @@ octavia_iptables_rules: octavia_wsgi_processes_max: 16 octavia_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, octavia_wsgi_processes_max] | min }}" octavia_wsgi_threads: 1 -octavia_wsgi_buffer_size: 65535 octavia_uwsgi_bind_address: "0.0.0.0" octavia_api_uwsgi_ini_overrides: {} diff --git a/tasks/main.yml b/tasks/main.yml index a6d78de9..17e7fe12 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -93,9 +93,15 @@ tags: - octavia-install -- import_tasks: octavia_uwsgi.yml +- name: Import uwsgi role + import_role: + name: uwsgi + vars: + uwsgi_services: "{{ uwsgi_octavia_services }}" + uwsgi_install_method: "{{ octavia_install_method }}" tags: - octavia-config + - uwsgi - name: Run the systemd service role import_role: diff --git a/tasks/octavia_policy.yml b/tasks/octavia_policy.yml index 953c35ee..43d5b671 100644 --- a/tasks/octavia_policy.yml +++ b/tasks/octavia_policy.yml @@ -24,4 +24,5 @@ config_type: "json" notify: - Restart octavia services + - Restart uwsgi services when: octavia_legacy_policy diff --git a/tasks/octavia_post_install.yml b/tasks/octavia_post_install.yml index e1c7746b..df109882 100644 --- a/tasks/octavia_post_install.yml +++ b/tasks/octavia_post_install.yml @@ -136,3 +136,4 @@ config_type: "ini" notify: - Restart octavia services + - Restart uwsgi services \ No newline at end of file diff --git a/tasks/octavia_uwsgi.yml b/tasks/octavia_uwsgi.yml deleted file mode 100644 index 2df5b09f..00000000 --- a/tasks/octavia_uwsgi.yml +++ /dev/null @@ -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: "octavia-uwsgi.ini.j2" - dest: "/etc/uwsgi/{{ item.service_name }}.ini" - mode: "0744" - config_overrides: "{{ item.wsgi_overrides }}" - config_type: ini - with_items: "{{ filtered_octavia_services }}" - when: item.wsgi_app | default(False) - notify: - - Restart octavia services diff --git a/templates/octavia-uwsgi.ini.j2 b/templates/octavia-uwsgi.ini.j2 deleted file mode 100644 index 80dffcf4..00000000 --- a/templates/octavia-uwsgi.ini.j2 +++ /dev/null @@ -1,25 +0,0 @@ -[uwsgi] -uid = {{ octavia_system_user_name }} -gid = {{ octavia_system_group_name }} - -{% if octavia_install_method == 'source' %} -virtualenv = /openstack/venvs/octavia-{{ octavia_venv_tag }} -{% endif %} -wsgi-file = {{ octavia_bin }}/{{ item.wsgi_name }} -http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} - -master = true -enable-threads = true -processes = {{ octavia_wsgi_processes }} -threads = {{ octavia_wsgi_threads }} -exit-on-reload = true -die-on-term = true -lazy-apps = true -add-header = Connection: close -buffer-size = {{ octavia_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 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/debian.yml b/vars/debian.yml index 44e10f28..865c4dec 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -33,7 +33,3 @@ octavia_service_distro_packages: - octavia-worker - python-pymysql - python-systemd - - uwsgi - - uwsgi-plugin-python - -octavia_uwsgi_bin: '/usr/bin' diff --git a/vars/main.yml b/vars/main.yml index 4d9bb207..73555917 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -22,7 +22,8 @@ filtered_octavia_services: |- {% for key, value in octavia_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, @@ -36,3 +37,26 @@ filtered_octavia_services: |- {% endif %} {% endfor %} {{ services | sort(attribute='start_order') }} + +uwsgi_octavia_services: |- + {% set services = {} %} + {% for key, value in octavia_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': octavia_bin ~ '/' ~ value.wsgi_name, + 'wsgi_venv': ((octavia_install_method == 'source') | ternary(octavia_bin | dirname, None)), + 'uwsgi_uid': octavia_system_user_name, + 'uwsgi_guid': octavia_system_group_name, + 'uwsgi_processes': octavia_wsgi_processes, + 'uwsgi_threads': octavia_wsgi_threads + } + ) + %} + {% set _ = services.update({key: value}) %} + {% endif %} + {% endfor %} + {{ services }} diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 861ca2ce..be48b48e 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -29,8 +29,6 @@ octavia_service_distro_packages: - openstack-octavia-housekeeping - openstack-octavia-worker - systemd-python - - uwsgi - - uwsgi-plugin-python octavia_distro_openstack_clients_packages: - python-shade @@ -40,5 +38,3 @@ octavia_distro_openstack_clients_packages: - python-cinderclient - python-octaviaclient - python-openstackclient - -octavia_uwsgi_bin: '/usr/sbin' diff --git a/vars/source_install.yml b/vars/source_install.yml index 6fc48597..508e6eaa 100644 --- a/vars/source_install.yml +++ b/vars/source_install.yml @@ -2,4 +2,3 @@ octavia_package_list: "{{ octavia_distro_packages }}" _octavia_bin: "/openstack/venvs/octavia-{{ octavia_venv_tag }}/bin" -octavia_uwsgi_bin: "{{ _octavia_bin }}"