-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-nginx.yml
64 lines (57 loc) · 2.17 KB
/
deploy-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
61
62
63
64
---
- name: Setup nginx for grafana
hosts: monitoring
become: yes
gather_facts: True
vars_prompt:
- name: run_roles
prompt: "Install nginx from scratch? (yes/no)"
default: "no"
- name: generate_certificates
prompt: "Generate letsencrypt certificates? (yes/no)"
default: "no"
vars_files:
- "vars/main.yml"
roles:
- role: nginxinc.nginx
when: run_roles|bool
- role: auxilincom.letsencrypt
when: generate_certificates|bool and server_setup_letsencrypt_ssl|bool
tasks:
- name: setup nginx host file dirs
file: name=/etc/nginx/{{ item }} state=directory owner=root group=root
with_items:
- sites-available
- conf.d/http
- name: Assures /etc/nginx/ssl exists
file: path=/etc/nginx/ssl state=directory
when: server_setup_ssl|bool
- name: Copy ssl certiicate to /etc/nginx/ssl
copy: src=ssl-keys/{{ item.src }} dest={{ item.dest }} owner=root mode=744
with_items:
- {src: 'app.crt', dest: '{{ server_ssl_cert_path }}'}
- {src: 'app.key', dest: '{{ server_ssl_key_path }}'}
when: server_setup_ssl|bool
- name: Generate dhparams
shell: openssl dhparam -out /etc/nginx/dhparams.pem 4096
args:
creates: /etc/nginx/dhparams.pem
when: server_setup_letsencrypt_ssl|bool or server_setup_ssl|bool
- name: copy nginx virtual host file
template: src="templates/grafana-nginx-config.j2"
dest="/etc/nginx/sites-available/03_monitoring"
owner=root
group=root
when: not server_setup_letsencrypt_ssl|bool and not server_setup_ssl|bool
- name: copy nginx virtual host file for ssl
template: src="templates/grafana-nginx-config-with-ssl.j2"
dest="/etc/nginx/sites-available/03_monitoring"
owner=root
group=root
when: server_setup_letsencrypt_ssl|bool or server_setup_ssl|bool
- name: link nginx virtual host file
file: src="/etc/nginx/sites-available/03_monitoring"
dest="/etc/nginx/conf.d/http/03_monitoring.conf"
state=link
- name: restart nginx
service: name=nginx state=restarted