-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-generate-certificate.yaml
47 lines (39 loc) · 1.09 KB
/
02-generate-certificate.yaml
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
---
- hosts: host
name: SSL certificate generation
vars_files:
- variables/ssh.yaml
- variables/certificate.yaml
become: true
become_method: su
tasks:
- name: Update apt packages
apt:
update_cache: yes
- name: Install pip3
apt: name=python3-pip state=present
- name: Install cerbot
pip:
name:
- certbot
- certbot-nginx
executable: pip3
- name: Register cerbot
shell: |
certbot -n register --agree-tos --email {{ email }}
touch /etc/letsencrypt/.registered
args:
creates: /etc/letsencrypt/.registered
- name: Setup cronjob for renewal
cron:
name: certbot-renewal
job: "/bin/bash -lc '/usr/local/bin/certbot -q renew'"
minute: "0"
hour: "14"
- name: Install nginx
apt: name=nginx state=present
- name: Generate certificate
command: "/usr/local/bin/certbot -v -n --nginx certonly -d {{ primary_domain }},{{ sub_domain }}"
args:
creates: "/etc/letsencrypt/live/{{ primary_domain }}"
ignore_errors: true