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

63 lines
1.9 KiB
YAML
Raw Normal View History

- name: Put the config file in place
2019-12-09 17:10:02 +00:00
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: 'ports.conf' , dest: '/etc/{{ apache_service }}/' , mode: '0644' }
- { src: "iiab.conf",dest: "/etc/nginx/conf.d/" }
2019-11-20 08:46:55 +00:00
when: nginx_enabled
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
# 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-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
- 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
- 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