-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathnginx.yml
More file actions
61 lines (50 loc) · 1.38 KB
/
nginx.yml
File metadata and controls
61 lines (50 loc) · 1.38 KB
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
61
---
- name: ensure sites-available for nginx
file:
path: /etc/nginx/sites-available
state: directory
become: true
- name: ensure there is an nginx user
user:
name: nginx
comment: "Nginx user"
become: true
- name: ensure sites-enable for nginx
file:
path: /etc/nginx/sites-enabled
state: directory
become: true
- name: remove default nginx site
action: file path=/etc/nginx/sites-enabled/default state=absent
become: true
- name: write nginx.conf
action: template src=../templates/nginx.conf dest=/etc/nginx/nginx.conf
become: true
- name: enable nginx
become: true
action: service name=nginx enabled=true
- name: create nginx site config
template:
src: "../templates/nginx_site.conf"
dest: "/etc/nginx/sites-available/{{ app_name }}.conf"
become: true
notify:
- restart nginx
- import_tasks: ssl.yml
when: development_server == true
- name: check to see if ssl cert needs created
stat:
path: "{{ nginx_ssl_cert_path }}"
become: true
register: ssl_cert
- import_tasks: letsencrypt.yml
when: development_server == false and not ssl_cert.stat.exists
- name: link nginx config
file:
src: "/etc/nginx/sites-available/{{ app_name }}.conf"
dest: "/etc/nginx/sites-enabled/{{ app_name }}.conf"
state: "link"
become: true
- name: ensure nginx is restarted
become: true
action: service name=nginx state=restarted