2019-10-15 23:47:49 +00:00
|
|
|
- name: Put the config file in place
|
|
|
|
template:
|
|
|
|
src: '{{ item.src}}'
|
|
|
|
dest: '{{ item.dest }}'
|
|
|
|
with_items:
|
2019-10-22 11:05:06 +00:00
|
|
|
- { src: "server.conf",dest: "/etc/nginx/" }
|
|
|
|
- { src: "nginx.conf",dest: "/etc/nginx/" }
|
|
|
|
- { src: "usb-lib.conf",dest: "/etc/nginx/conf.d/" }
|
2019-11-21 14:34:37 +00:00
|
|
|
# - { src: "admin-console.ini",dest: "/etc/uwsgi/apps-enabled/" }
|
2019-11-18 18:40:09 +00:00
|
|
|
# the above should be enough once uwsgi is started
|
|
|
|
# - { src: "uwsgi.unit",dest: "/etc/systemd/system/uwsgi.socket" }
|
2019-10-22 11:05:06 +00:00
|
|
|
- { src: 'ports.conf' , dest: '/etc/{{ apache_service }}/' , mode: '0644' }
|
2019-11-20 08:46:55 +00:00
|
|
|
when: nginx_enabled
|
2019-10-15 23:47:49 +00:00
|
|
|
|
2019-10-22 11:05:06 +00:00
|
|
|
- name: Insure that apache2 is not running -- we may need port swap
|
|
|
|
systemd:
|
|
|
|
name: apache2
|
|
|
|
state: stopped
|
|
|
|
|
|
|
|
# optional services
|
2019-10-15 23:47:49 +00:00
|
|
|
- name: Install config for Admin Console
|
|
|
|
template:
|
2019-10-22 11:05:06 +00:00
|
|
|
src: admin-console-nginx.conf
|
2019-10-15 23:47:49 +00:00
|
|
|
# Comment one or the other to revert from nginx back to apache2, if required
|
2019-10-22 11:05:06 +00:00
|
|
|
# src: admin-console-apache.conf
|
|
|
|
dest: /etc/nginx/conf.d/admin-console.conf
|
2019-11-20 08:46:55 +00:00
|
|
|
when: admin_console_enabled and nginx_enabled
|
2019-10-15 23:47:49 +00:00
|
|
|
|
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
|
|
|
|
- name: Install proxpass to apache running on localhost port {{ apache_port }}
|
2019-10-22 05:11:25 +00:00
|
|
|
include_tasks: uses_apache.yml
|
2019-11-20 08:46:55 +00:00
|
|
|
when: nginx_enabled
|
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/
|
|
|
|
|
|
|
|
- name: Install proxpass to other services 'dual mode' roles
|
2019-10-22 11:05:06 +00:00
|
|
|
include_tasks: only_nginx.yml
|
2019-11-20 08:46:55 +00:00
|
|
|
when: nginx_enabled
|
2019-10-22 17:05:11 +00:00
|
|
|
|
|
|
|
- name: Stop and disable nginx when not nginx_enabled
|
|
|
|
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
|
|
|
|
2019-11-28 13:30:27 +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
|
2019-11-20 08:46:55 +00:00
|
|
|
- name: Enable Apache (a2ensite) for 'dual mode' for the role when NGINX is diabled
|
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
|
|
|
|
2019-10-15 23:47:49 +00:00
|
|
|
- name: Since we stopped apache2, start it again
|
2019-10-22 11:05:06 +00:00
|
|
|
systemd:
|
|
|
|
name: apache2
|
|
|
|
state: restarted
|
2019-10-23 06:11:40 +00:00
|
|
|
enabled: true
|
2019-10-22 11:05:06 +00:00
|
|
|
daemon_reload: yes
|
2019-11-20 08:46:55 +00:00
|
|
|
when: apache_enabled
|
2019-10-22 11:05:06 +00:00
|
|
|
|
|
|
|
- name: Restart nginx to pick up the config files installed
|
|
|
|
systemd:
|
|
|
|
name: nginx
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
2019-11-20 08:46:55 +00:00
|
|
|
when: nginx_enabled
|
2019-11-20 20:42:26 +00:00
|
|
|
|
2019-11-21 14:34:37 +00:00
|
|
|
#- name: Enable the uwsgi systemd service
|
|
|
|
# systemd:
|
|
|
|
# name: uwsgi
|
|
|
|
# state: restarted
|
|
|
|
# enabled: true
|
|
|
|
# when: admin_console_enabled and nginx_enabled
|