blob: 7a0589ff0d4af829dfc851e55955fd237fb8959c (
plain)
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
|
---
- name: install nginx packages
become: yes
apt: name="nginx"
- name: install site
become: yes
template: src="{{nginx_conf_src}}" dest="/etc/nginx/sites-available/{{nginx_conf_dst}}"
notify: restart nginx
# https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx
- name: add certbot (letsencrypt) repo
become: yes
apt_repository: repo="ppa:certbot/certbot"
when: nginx_enable_ssl
- name: install nginx packages
become: yes
apt: name="python-certbot-nginx"
notify: restart nginx
when: nginx_enable_ssl
- name: install certbot in nginx
become: yes
command: "certbot certonly --nginx -n --agree-tos -d {{nginx_server_name}} -m {{nginx_admin_email}}"
notify: restart nginx
when: nginx_enable_ssl
- name: disable default site
become: yes
file: path="/etc/nginx/sites-enabled/default" state="absent"
notify: restart nginx
- name: enable site
become: yes
file:
src: "/etc/nginx/sites-available/{{nginx_conf_dst}}"
dest: "/etc/nginx/sites-enabled/{{nginx_conf_dst}}"
state: "link"
notify: restart nginx
- name: enable nginx service
become: yes
systemd: name="nginx" enabled="yes" state="started"
|