2020-01-11 20:11:38 +00:00
|
|
|
- name: Remove stale files (usb-lib.conf, modules.conf) from {{ nginx_config_dir }}
|
2019-12-17 15:49:08 +00:00
|
|
|
file:
|
2020-01-12 17:12:49 +00:00
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: absent
|
2019-12-17 15:49:08 +00:00
|
|
|
with_items:
|
2020-01-04 06:54:40 +00:00
|
|
|
- { path: "{{ nginx_config_dir }}/usb-lib.conf" }
|
|
|
|
- { path: "{{ nginx_config_dir }}/modules.conf" }
|
2019-12-17 15:49:08 +00:00
|
|
|
|
2020-01-11 20:11:38 +00:00
|
|
|
- name: Ensure that Apache (({{ apache_service }})) is not running -- we may need port swap
|
2019-10-22 11:05:06 +00:00
|
|
|
systemd:
|
2020-01-11 20:11:38 +00:00
|
|
|
name: "{{ apache_service }}"
|
2019-10-22 11:05:06 +00:00
|
|
|
state: stopped
|
|
|
|
|
2020-01-04 12:28:19 +00:00
|
|
|
- name: "Install from template: /etc/nginx/server.conf, /etc/nginx/nginx.conf, /etc/{{ apache_service }}/ports.conf, {{ nginx_config_dir }}/iiab.conf"
|
|
|
|
template:
|
2020-01-12 17:12:49 +00:00
|
|
|
src: "{{ item.src}}"
|
|
|
|
dest: "{{ item.dest }}"
|
2020-01-04 12:28:19 +00:00
|
|
|
with_items:
|
2020-01-12 17:12:49 +00:00
|
|
|
- { src: 'server.conf', dest: '/etc/nginx/' }
|
|
|
|
- { src: 'nginx.conf', dest: '/etc/nginx/' }
|
|
|
|
- { src: 'ports.conf', dest: "/etc/{{ apache_service }}/" }
|
|
|
|
- { src: 'iiab.conf.j2', dest: "{{ nginx_config_dir }}/iiab.conf" }
|
2020-01-04 12:28:19 +00:00
|
|
|
when: nginx_enabled | bool
|
|
|
|
|
2019-10-22 11:05:06 +00:00
|
|
|
# the below slides in nginx's proxypass config files for apache on localhost
|
|
|
|
# via the ports.conf file installed above
|
2020-01-12 17:12:49 +00:00
|
|
|
#- name: Install proxpass to Apache running on localhost port {{ apache_port }}
|
2020-01-04 12:28:19 +00:00
|
|
|
# include_tasks: uses_apache.yml
|
2020-01-12 17:12:49 +00:00
|
|
|
# when: apache_enabled | bool
|
2019-10-15 23:47:49 +00:00
|
|
|
|
2019-10-22 11:05:06 +00:00
|
|
|
# the below task contains the same logic contained in the playbooks to enable
|
2019-10-22 17:05:11 +00:00
|
|
|
# 'runrole nginx' to do the right thing but with the 'src' path set to role's
|
|
|
|
# templates path ie roles/<rolename>/template/
|
2020-01-04 12:28:19 +00:00
|
|
|
#- name: Install proxpass to other services 'dual mode' roles
|
|
|
|
# include_tasks: only_nginx.yml
|
2020-01-12 17:12:49 +00:00
|
|
|
# when: nginx_enabled | bool
|
2019-10-22 17:05:11 +00:00
|
|
|
|
2020-01-12 22:21:56 +00:00
|
|
|
- name: Stop & Disable 'nginx' systemd service, when not nginx_enabled
|
2019-10-22 17:05:11 +00:00
|
|
|
systemd:
|
|
|
|
name: nginx
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
2019-11-20 08:46:55 +00:00
|
|
|
when: not nginx_enabled
|
2019-10-22 17:05:11 +00:00
|
|
|
|
2020-01-12 17:12:49 +00:00
|
|
|
- name: Disable Apache port {{ apache_port }} localhost only, when not nginx_enabled
|
2019-10-22 17:05:11 +00:00
|
|
|
template:
|
|
|
|
dest: /etc/{{ apache_service }}/ports.conf
|
|
|
|
src: stock-apache-ports.conf
|
2019-11-20 08:46:55 +00:00
|
|
|
when: not nginx_enabled
|
2019-10-22 17:05:11 +00:00
|
|
|
|
|
|
|
# should have the logic to handle both modes in the playbook
|
2020-01-12 17:12:49 +00:00
|
|
|
#- name: Enable Apache (a2ensite) for 'dual mode' for the role when NGINX is disabled
|
2020-01-04 12:28:19 +00:00
|
|
|
# include_tasks: disable.yml
|
|
|
|
# when: not nginx_enabled
|
2019-10-22 11:05:06 +00:00
|
|
|
|
2020-01-11 20:11:38 +00:00
|
|
|
- name: Enable & Restart Apache, since we stopped it ({{ apache_service }})
|
2019-10-22 11:05:06 +00:00
|
|
|
systemd:
|
2020-01-11 20:11:38 +00:00
|
|
|
name: "{{ apache_service }}"
|
|
|
|
daemon_reload: yes
|
2019-10-22 11:05:06 +00:00
|
|
|
state: restarted
|
2019-10-23 06:11:40 +00:00
|
|
|
enabled: true
|
2020-01-12 17:12:49 +00:00
|
|
|
when: apache_enabled or not nginx_enabled
|
2019-10-22 11:05:06 +00:00
|
|
|
|
2020-01-11 20:11:38 +00:00
|
|
|
- name: Enable & Restart NGINX, to pick up the config files installed
|
2019-10-22 11:05:06 +00:00
|
|
|
systemd:
|
|
|
|
name: nginx
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
2020-01-11 20:11:38 +00:00
|
|
|
when: nginx_enabled | bool
|