Skip to content

Commit e73bfcf

Browse files
committed
v1.2
1 parent 98f29ff commit e73bfcf

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Each host has the following variables available:
2323
* *account_key*: (str) path where to store letsencrypt account key.
2424
* *account\_email*: (str) email address to get notifications when any certificate needs renewal.
2525
* *agreed*: (bool) say 'yes' to letsencrypt TOS.
26+
* *testing*: (bool) default is 'yes', change to 'no' when you ready for production.
2627

2728
## Usage
2829
* Clone this repository, edit 'hosts' or use it as template.

src/host_vars/example.org

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ account_email: certs@example.org
2727
# agreement is REQUIRED to be able to sign your certificate with letsencrpt, change the following to yes if you agreed.
2828
agreed: no
2929

30+
# set testing to "no" when used on production domains
31+
testing: yes
32+
33+
3034

3135

3236

src/install_tls.yaml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
loop: "{{ crts.results }}"
5252
when: not item.stat.exists or item.stat.mtime | older_than(days=80)
5353

54-
- name: generate lets encrypt ssl
54+
- name: generate lets encrypt ssl (testing)
5555
acme_certificate:
5656
acme_version: 2
5757
account_key: "{{ account_key }}"
@@ -60,11 +60,25 @@
6060
chain_dest: "{{ item.invocation.module_args.path | dirname }}/crt.intermediate.new"
6161
fullchain_dest: "{{ item.invocation.module_args.path | dirname }}/crt.chained.new"
6262
terms_agreed: "{{ agreed | default('no') }}"
63-
acme_directory: https://acme-v02.api.letsencrypt.org/directory
63+
acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory
6464
loop: "{{ crts.results }}"
65-
when: not item.stat.exists or item.stat.mtime | older_than(days=80)
65+
when: testing and (not item.stat.exists or item.stat.mtime | older_than(days=80))
6666
register: data
6767

68+
- name: generate lets encrypt ssl (production)
69+
acme_certificate:
70+
acme_version: 2
71+
account_key: "{{ account_key }}"
72+
csr: "{{ item.invocation.module_args.path | dirname }}/csr.new"
73+
dest: "{{ item.invocation.module_args.path | dirname }}/crt.thin.new"
74+
chain_dest: "{{ item.invocation.module_args.path | dirname }}/crt.intermediate.new"
75+
fullchain_dest: "{{ item.invocation.module_args.path | dirname }}/crt.chained.new"
76+
terms_agreed: "{{ agreed | default('no') }}"
77+
acme_directory: https://acme-v02.api.letsencrypt.org/directory
78+
loop: "{{ crts.results }}"
79+
when: not testing and (not item.stat.exists or item.stat.mtime | older_than(days=80))
80+
register: data
81+
6882
- name: create directories for challanges
6983
file:
7084
path: "/var/www/{{ item.invocation.module_args.fullchain_dest | dirname | basename }}/{{ item | acme_get('resource') | dirname }}"
@@ -82,7 +96,7 @@
8296
when: item.changed
8397
loop: "{{ data.results }}"
8498

85-
- name: ask letsencrypt to validate
99+
- name: ask letsencrypt to validate (testing)
86100
acme_certificate:
87101
acme_version: 2
88102
account_key: "{{ account_key }}"
@@ -93,9 +107,25 @@
93107
terms_agreed: "{{ agreed | default('no') }}"
94108
acme_directory: https://acme-v02.api.letsencrypt.org/directory
95109
data: "{{ item }}"
96-
when: item.changed
110+
when: testing and item.changed
97111
loop: "{{ data.results }}"
98112

113+
114+
- name: ask letsencrypt to validate (production)
115+
acme_certificate:
116+
acme_version: 2
117+
account_key: "{{ account_key }}"
118+
csr: "{{ item.invocation.module_args.dest | dirname }}/csr.new"
119+
dest: "{{ item.invocation.module_args.dest }}"
120+
chain_dest: "{{ item.invocation.module_args.chain_dest }}"
121+
fullchain_dest: "{{ item.invocation.module_args.fullchain_dest}}"
122+
terms_agreed: "{{ agreed | default('no') }}"
123+
acme_directory: https://acme-v02.api.letsencrypt.org/directory
124+
data: "{{ item }}"
125+
when: not testing and item.changed
126+
loop: "{{ data.results }}"
127+
128+
99129
- name: rename crt.chained.new -> crt.chained
100130
copy:
101131
force: yes

0 commit comments

Comments
 (0)