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

119 lines
3.5 KiB
YAML
Raw Normal View History

- name: Insure that apache2 is not running -- we may need port swap
service:
name: apache2
enabled: False
state: stopped
ignore_errors: True
- name: Install nginx required and helper packages
package: name={{ item }} state=present
with_items:
- nginx-extras
- uwsgi
- uwsgi-plugin-python
- php-fpm
- libnginx-mod-http-subs-filter
- name: Put the config file in place
template:
src: '{{ item.src}}'
dest: '{{ item.dest }}'
with_items:
- { src: "server.conf",dest: "/etc/nginx/" }
- { src: "nginx.conf",dest: "/etc/nginx/" }
- { src: "usb-lib.conf",dest: "/etc/nginx/conf.d/" }
- { src: "admin-console.ini",dest: "/etc/uwsgi/apps-enabled/" }
- { src: "uwsgi.unit",dest: "/etc/systemd/system/" }
# optional services
- { src: "kiwix.conf",dest: "/etc/nginx/conf.d/" }
- name: Add http server user to shadow group, so it can authenticate Admin Console
user:
name: "{{ apache_user }}"
groups: shadow
- name: Remove the nginx default config
file: path=/etc/nginx/sites-enabled/default state=absent
- name: Install config for Admin Console
template:
src: admin-console-nginx.conf
# Comment one or the other to revert from nginx back to apache2, if required
# src: admin-console-apache.conf
dest: /etc/nginx/conf.d/admin-console.conf
when: admin_console_enabled | bool
- name: Enable the uwsgi systemd service
service:
name: uwsgi
state: started
enabled: True
- name: Install ports.conf when nginx_enabled, from templates
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: 0644
with_items:
- { src: 'ports.conf' , dest: '/etc/{{ apache_service }}/' , mode: '0644' }
when: is_debuntu | bool and nginx_enabled | bool
- name: Install nginx's config file from template, if moodle_enabled
template:
src: moodle-nginx.conf.j2
dest: "/etc/nginx/conf.d/moodle-nginx.conf"
owner: root
group: root
mode: 0644
when: moodle_enabled | bool
- name: Install /etc/nginx/conf.d/elgg-nginx.conf from template
template:
src: elgg-nginx.conf
dest: "/etc/nginx/conf.d/elgg-nginx.conf"
when: elgg_enabled | bool
- name: Install /etc/nginx/lokole-nginx.conf from template
template:
src: lokole-nginx.conf.j2
dest: "/etc/nginx/conf.d/lokole-nginx.conf"
when: lokole_enabled | bool
- name: Install MediaWiki's nginx conf.d file from template
template:
src: mediawiki-nginx.conf.j2
dest: /etc/nginx/conf.d/mediawiki-nginx.conf
when: mediawiki_enabled | bool
- name: Install WordPress's nginx conf.d file from template
template: src=nextcloud-nginx.conf dest=/etc/nginx/conf.d/nextcloud-nginx.conf
when: nextcloud_enabled | bool
- name: Install NodeRed's nginx conf.d file from template
template:
src: nodered-nginx.conf.j2
dest: /etc/nginx/conf.d/nodered-nginx.conf
owner: root
group: root
mode: 0666
when: nodered_enabled | bool
- name: Install WordPress's nginx conf.d file from template
template:
src: wordpress-nginx.conf
dest: /etc/nginx/conf.d/
when: wordpress_enabled | bool
- name: Make sure nginx picks up the config
service:
name: nginx
state: restarted
when: nginx_enabled | bool
# it might not be installed yet, so ignore errors
- name: Since we stopped apache2, start it again
service: name=apache2 state=started enabled=True
when: apache_enabled | bool
ignore_errors: True