-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathansible-https.yml
61 lines (50 loc) · 1.42 KB
/
ansible-https.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
---
- name: install nginx and ssl certificates in ansible vm
hosts: all
tasks:
- name: install and configure nginx
block:
- name: "APT - install nginx"
apt:
name: nginx
update_cache: yes
- name: copy nginx conf file
template:
src: ../files/nginx/demo.nginx.j2
dest: "/etc/nginx/sites-available/django"
- name: copy nginx https conf file
template:
src: ../files/nginx/demo.https.nginx.j2
dest: "/etc/nginx/sites-available/djangossl"
- name: copy certificates
copy:
src: "{{item}}"
dest: /etc/ssl/private/
with_items:
- ../files/certs/django/certificate.crt
- ../files/certs/django/private.key
- name: enable django site in nginx
file:
src: "/etc/nginx/sites-available/django"
dest: "/etc/nginx/sites-enabled/django"
state: link
notify: restart nginx
- name: enable djangossl site in nginx
file:
src: "/etc/nginx/sites-available/djangossl"
dest: "/etc/nginx/sites-enabled/djangossl"
state: link
notify: restart nginx
- name: de-activate default nginx site
file:
path: /etc/nginx/sites-enabled/default
state: absent
notify: restart nginx
become: yes
become_user: root
handlers:
- name: restart nginx
service:
name: nginx
state: restarted
become: yes