-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.yml
60 lines (54 loc) · 1.22 KB
/
nginx.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- hosts: webservers
pre_tasks:
- name: update repositories cache
become: yes
apt:
update_cache: yes
tasks:
- name: install nginx
become: yes
apt:
name: nginx
- name: delete default nginx site
become: yes
file:
path: /etc/nginx/sites-available/default
state: absent
notify: restart nginx
- name: configure nginx
become: yes
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
owner: root
group: root
mode: '0644'
notify: restart nginx
- name: create the site root directory
become: yes
file:
path: "{{ root }}"
owner: root
group: www-data
mode: u=rwx,g=rwx,o=r
state: directory
- name: configure site
become: yes
template:
src: site.j2
dest: /etc/nginx/sites-available/{{ domain }}
owner: root
group: root
mode: '0644'
notify: restart nginx
- name: Create symbolic link
become: yes
file:
src: /etc/nginx/sites-available/{{ domain }}
dest: /etc/nginx/sites-enabled/{{ domain }}
state: link
notify: restart nginx
handlers:
- name: restart nginx
command: "kill -HUP 'cat /var/run/nginx.pid'"