2020-01-14 10:23:21 +00:00
|
|
|
---
|
|
|
|
- name: Install Nginx
|
|
|
|
apt:
|
|
|
|
name: nginx
|
|
|
|
|
|
|
|
- name: Create directories for Nginx configuration
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: '{{ item }}'
|
2021-09-01 20:53:48 +00:00
|
|
|
mode: 'u=rwx,go=rx'
|
2020-01-14 10:23:21 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items:
|
|
|
|
- '{{ common__nginx__conf_dir }}'
|
|
|
|
- '{{ common__nginx__confd_dir }}'
|
|
|
|
- '{{ common__nginx__available_dir }}'
|
|
|
|
- '{{ common__nginx__enabled_dir }}'
|
2020-02-06 14:47:51 +00:00
|
|
|
- '{{ common__nginx__snippets_dir }}'
|
2020-07-13 20:09:31 +00:00
|
|
|
notify: common | Restart Nginx
|
|
|
|
|
2020-07-14 20:37:22 +00:00
|
|
|
- name: Disable Nginx access log
|
|
|
|
lineinfile:
|
|
|
|
path: '{{ common__nginx__conf_dir }}/nginx.conf'
|
|
|
|
regexp: '^(\s*)#?\s*access_log\s+\S+\s*;\s*$'
|
|
|
|
line: '\1#access_log /var/log/nginx/access.log;'
|
|
|
|
backrefs: true
|
2020-07-14 21:01:08 +00:00
|
|
|
notify: common | Restart Nginx
|
2020-07-14 20:37:22 +00:00
|
|
|
|
|
|
|
- name: Disable Nginx error log
|
|
|
|
lineinfile:
|
|
|
|
path: '{{ common__nginx__conf_dir }}/nginx.conf'
|
|
|
|
regexp: '^(\s*)#?\s*error_log\s+\S+\s*;\s*$'
|
|
|
|
line: '\1#error_log /var/log/nginx/error.log;'
|
|
|
|
backrefs: true
|
2020-07-14 21:01:08 +00:00
|
|
|
notify: common | Restart Nginx
|
2020-07-14 20:37:22 +00:00
|
|
|
|
2020-07-13 20:09:31 +00:00
|
|
|
- name: Install Nginx log config
|
|
|
|
copy:
|
|
|
|
src: 'files/nginx/syslog.conf'
|
|
|
|
dest: '{{ common__nginx__confd_dir }}/syslog.conf'
|
2021-09-01 20:53:48 +00:00
|
|
|
mode: 'u=rw,go=r'
|
2020-07-13 20:09:31 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
notify: common | Restart Nginx
|
2020-01-14 10:23:21 +00:00
|
|
|
|
|
|
|
- name: Remove Nginx default site
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: '{{ common__nginx__enabled_dir }}/default'
|
2020-01-20 18:00:02 +00:00
|
|
|
when: common__nginx__remove_default|bool
|
2020-01-14 10:23:21 +00:00
|
|
|
notify: common | Restart Nginx
|
|
|
|
|
|
|
|
- name: Add Nginx upstreams
|
|
|
|
template:
|
|
|
|
src: 'templates/nginx/upstream.conf'
|
|
|
|
dest: '{{ common__nginx__confd_dir }}/upstream-{{ item.name }}.conf'
|
2021-09-01 20:53:48 +00:00
|
|
|
mode: 'u=rw,go=r'
|
2020-01-14 10:23:21 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ common__nginx__upstreams }}'
|
|
|
|
notify: common | Restart Nginx
|
|
|
|
|
|
|
|
- name: Add Nginx sites
|
|
|
|
template:
|
|
|
|
src: 'templates/nginx/{{ item.type }}.conf'
|
|
|
|
dest: '{{ common__nginx__available_dir }}/{{ item.domain }}.conf'
|
2021-09-01 20:53:48 +00:00
|
|
|
mode: 'u=rw,go=r'
|
2020-01-14 10:23:21 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ common__nginx__sites }}'
|
|
|
|
notify: common | Restart Nginx
|
|
|
|
|
|
|
|
- name: Enable Nginx sites
|
|
|
|
file:
|
|
|
|
state: link
|
|
|
|
src: '{{ common__nginx__available_dir }}/{{ item.domain }}.conf'
|
|
|
|
dest: '{{ common__nginx__enabled_dir }}/{{ item.domain }}.conf'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
with_items: '{{ common__nginx__sites }}'
|
|
|
|
notify: common | Restart Nginx
|