1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00
iiab/roles/nginx/tasks/main.yml

71 lines
2.4 KiB
YAML
Raw Normal View History

2020-01-11 20:11:38 +00:00
- name: "Install from template: /etc/nginx/server.conf, /etc/nginx/nginx.conf, /etc/{{ apache_service }}/ports.conf, {{ nginx_config_dir }}/iiab.conf"
2019-12-09 17:10:02 +00:00
template:
2020-01-11 20:11:38 +00:00
src: "{{ item.src}}"
dest: "{{ item.dest }}"
with_items:
2020-01-11 20:11:38 +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" }
when: nginx_enabled | bool
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:
state: absent
2020-01-11 20:11:38 +00:00
path: "{{ item.path }}"
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
# the below slides in nginx's proxypass config files for apache on localhost
# via the ports.conf file installed above
2020-01-11 20:11:38 +00:00
- name: Install proxpass to Apache running on localhost port {{ apache_port }}
2019-10-22 05:11:25 +00:00
include_tasks: uses_apache.yml
2020-01-11 20:11:38 +00:00
when: nginx_enabled | bool
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/
- name: Install proxpass to other services 'dual mode' roles
2019-10-22 11:05:06 +00:00
include_tasks: only_nginx.yml
2020-01-11 20:11:38 +00:00
when: nginx_enabled | bool
2019-10-22 17:05:11 +00:00
2020-01-11 20:11:38 +00:00
- name: Stop and disable NGINX 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
- name: Disable Apache port {{ apache_port }} localhost only
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-11 20:11:38 +00:00
- name: Enable Apache (a2ensite) for 'dual mode' for the role when NGINX is disabled
2019-10-22 17:05:11 +00:00
include_tasks: disable.yml
2019-11-20 08:46:55 +00:00
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-11 20:11:38 +00:00
when: apache_enabled | bool
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