1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 19:22:24 +00:00
iiab/roles/nginx/tasks/enable-or-disable.yml

40 lines
1.4 KiB
YAML

- 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/<OS>.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/<OS>.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