common/tasks/nginx.yml

55 lines
1.4 KiB
YAML
Raw Normal View History

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 }}'
mode: 'u=rwx,g=rx,o=rx'
owner: root
group: root
with_items:
- '{{ common__nginx__conf_dir }}'
- '{{ common__nginx__confd_dir }}'
- '{{ common__nginx__available_dir }}'
- '{{ common__nginx__enabled_dir }}'
- 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'
mode: 'u=rw,g=r,o=r'
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'
mode: 'u=rw,g=r,o=r'
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