- name: Ensure that Apache (({{ apache_service }})) is not running -- we may need port swap systemd: name: "{{ apache_service }}" # apache2 or httpd, per /opt/iiab/iiab/vars/.yml state: stopped - name: Install /etc/{{ apache_service }}/ports.conf from template 1 of 2 (ports.conf.j2) if nginx_enabled, to enable Apache port {{ apache_port }} localhost only template: src: ports.conf.j2 dest: "/etc/{{ apache_service }}/ports.conf" when: nginx_enabled | bool - name: Install /etc/{{ apache_service }}/ports.conf from template 2 of 2 (stock-apache-ports.conf) if not nginx_enabled, to disable Apache port {{ apache_port }} localhost only template: src: stock-apache-ports.conf dest: "/etc/{{ apache_service }}/ports.conf" when: not nginx_enabled - name: Enable & Restart '{{ apache_service }}' if apache_enabled or not nginx_enabled, since we stopped it systemd: name: "{{ apache_service }}" # apache2 or httpd, per /opt/iiab/iiab/vars/.yml daemon_reload: yes state: restarted enabled: true when: apache_enabled or not nginx_enabled - name: Enable & (Re)Start 'nginx' systemd service, if nginx_enabled systemd: name: nginx daemon_reload: yes enabled: yes state: restarted when: nginx_enabled | bool - name: Disable & Stop 'nginx' systemd service, if not nginx_enabled systemd: name: nginx enabled: no state: stopped when: not nginx_enabled