diff --git a/roles/wsgi_website/tasks/main.yml b/roles/wsgi_website/tasks/main.yml index 0bbea9ad15eb05557c3db6cbfe8fa07d326a5b19..1459a1109aeb52e59904954928962fcd782ab5a7 100644 --- a/roles/wsgi_website/tasks/main.yml +++ b/roles/wsgi_website/tasks/main.yml @@ -74,8 +74,9 @@ name: "{{ item }}" state: present with_items: "{{ packages }}" + register: install_extra_packages notify: - - "Restart website {{ fqdn }}" + - Restart WSGI services - name: Set-up MariaDB mysql_config symbolic link for compatibility (workaround for Debian bug 766996) file: @@ -134,8 +135,9 @@ - package: futures version: "{{ futures_version }}" when: "not wsgi_requirements" + register: install_wsgi_server notify: - - "Restart website {{ fqdn }}" + - Restart WSGI services - include: requirements.yml when: "wsgi_requirements" @@ -148,8 +150,9 @@ state: present virtualenv: "{{ home }}/virtualenv" with_items: "{{ virtualenv_packages }}" + register: install_additional_packages_in_virtualenv notify: - - "Restart website {{ fqdn }}" + - Restart WSGI services - name: Deploy systemd socket configuration for website template: @@ -158,9 +161,10 @@ owner: root group: root mode: 0644 + register: deploy_systemd_socket_configuration notify: - Reload systemd - - "Restart website {{ fqdn }}" + - Restart WSGI services - name: Deploy systemd service configuration for website template: @@ -169,9 +173,10 @@ owner: root group: root mode: 0644 + register: deploy_systemd_service_configuration notify: - Reload systemd - - "Restart website {{ fqdn }}" + - Restart WSGI services - name: Enable the website service service: @@ -234,6 +239,32 @@ notify: - Restart nginx +- name: Set-up empty list of WSGI services to restart + set_fact: + wsgi_services_to_restart: [] + when: "wsgi_services_to_restart is not defined" + tags: + - handlers + +- name: Add service to list of WSGI services to restart + set_fact: + wsgi_services_to_restart: "{{ wsgi_services_to_restart + [ fqdn ] }}" + when: | + fqdn not in wsgi_services_to_restart and + ((install_extra_packages is defined and install_extra_packages.changed) or + (install_wsgi_server is defined and install_wsgi_server.changed) or + (install_additional_packages_in_virtualenv is defined and install_additional_packages_in_virtualenv.changed) or + (deploy_systemd_socket_configuration is defined and deploy_systemd_socket_configuration.changed) or + (deploy_systemd_service_configuration is defined and deploy_systemd_service_configuration.changed) or + (install_gunciron_via_requirements is defined and install_gunciron_via_requirements.changed) or + (handlers | default(False) | bool() == True)) + tags: + - handlers + # [ANSIBLE0016] Tasks that run when changed should likely be handlers + # This specific task is used in order to work around inability of Ansible + # to provide properly parametrised handlers for reusable roles. + - skip_ansible_lint + - name: Explicitly run all handlers include: ../handlers/main.yml when: "handlers | default(False) | bool() == True"