2021-09-18 15:37:57 -04:00
|
|
|
---
|
|
|
|
- name: Install Nginx
|
|
|
|
apt:
|
|
|
|
name: nginx
|
|
|
|
|
|
|
|
- name: Create directories for Nginx configuration
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: '{{ item }}'
|
|
|
|
mode: 'u=rwx,go=rx'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
2023-05-29 08:30:47 -04:00
|
|
|
- '{{ nginx__dir_etc }}'
|
2021-09-18 15:37:57 -04:00
|
|
|
- '{{ nginx__confd_dir }}'
|
|
|
|
- '{{ nginx__available_dir }}'
|
|
|
|
- '{{ nginx__enabled_dir }}'
|
|
|
|
- '{{ nginx__snippets_dir }}'
|
|
|
|
|
2023-05-29 09:14:15 -04:00
|
|
|
- name: Create directories for Nginx HTML files
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: '{{ item }}'
|
|
|
|
mode: 'u=rwx,go=rx'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
|
|
|
- '{{ nginx__dir_www }}'
|
|
|
|
- '{{ nginx__dir_www_html }}'
|
|
|
|
|
2023-03-30 02:20:55 -04:00
|
|
|
- name: Install Nginx config
|
2021-09-18 15:37:57 -04:00
|
|
|
notify: nginx | Restart Nginx
|
2023-03-30 02:20:55 -04:00
|
|
|
copy:
|
|
|
|
src: 'files/nginx.conf'
|
2023-05-29 08:30:47 -04:00
|
|
|
dest: '{{ nginx__dir_etc }}/nginx.conf'
|
2023-03-30 02:20:55 -04:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-09-18 15:37:57 -04:00
|
|
|
|
2023-03-30 02:26:01 -04:00
|
|
|
- name: Install Nginx stream config
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
copy:
|
2023-03-30 02:52:59 -04:00
|
|
|
content: "{{ nginx__stream }}\n"
|
2023-05-29 08:30:47 -04:00
|
|
|
dest: '{{ nginx__dir_etc }}/stream.conf'
|
2023-03-30 02:26:01 -04:00
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
2021-09-18 15:37:57 -04:00
|
|
|
- name: Remove Nginx default site
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: '{{ nginx__enabled_dir }}/default'
|
|
|
|
when: nginx__remove_default|bool
|
|
|
|
|
|
|
|
- name: Add Nginx upstreams
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2021-09-20 00:38:05 -04:00
|
|
|
src: 'templates/upstream.conf'
|
2021-09-18 15:37:57 -04:00
|
|
|
dest: '{{ nginx__confd_dir }}/upstream-{{ item.name }}.conf'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ nginx__upstreams }}'
|
|
|
|
|
|
|
|
- name: Add Nginx sites
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
2021-09-20 00:39:11 -04:00
|
|
|
src: 'templates/site.conf'
|
2021-09-18 15:37:57 -04:00
|
|
|
dest: '{{ nginx__available_dir }}/{{ item.domain }}.conf'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ nginx__sites }}'
|
|
|
|
|
|
|
|
- name: Enable Nginx sites
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
file:
|
|
|
|
state: link
|
|
|
|
src: '{{ nginx__available_dir }}/{{ item.domain }}.conf'
|
|
|
|
dest: '{{ nginx__enabled_dir }}/{{ item.domain }}.conf'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ nginx__sites }}'
|
2023-05-29 09:14:15 -04:00
|
|
|
|
|
|
|
- name: Install maintenance files
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
copy:
|
|
|
|
src: 'files/{{ item }}'
|
|
|
|
dest: '{{ nginx__dir_www_html }}/{{ item }}'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
|
|
|
- 'maintenance.html'
|
|
|
|
- 'maintenance.jpg'
|
|
|
|
|
|
|
|
- name: Install maintenance snippet
|
|
|
|
notify: nginx | Restart Nginx
|
|
|
|
template:
|
|
|
|
src: 'templates/maintenance.conf'
|
|
|
|
dest: '{{ nginx__snippets_dir }}/maintenance.conf'
|
|
|
|
mode: 'u=rw,go=r'
|
|
|
|
owner: root
|
|
|
|
group: root
|