Skip to content

Commit 5b80ef7

Browse files
author
Philipp Gassmann
committed
add cron_success_command
1 parent 5600c44 commit 5b80ef7

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

manifests/init.pp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
#
3030
class letsencrypt_nginx (
3131
$default_server_name = 'default',
32-
$webroot = '/var/lib/letsencrypt/webroot',
33-
$firstrun_webroot = undef, # For Debian & Nginx: /usr/share/nginx/html
34-
$firstrun_standalone = false,
35-
$locations = {},
32+
$webroot = '/var/lib/letsencrypt/webroot',
33+
$firstrun_webroot = undef, # For Debian & Nginx: /usr/share/nginx/html
34+
$firstrun_standalone = false,
35+
$locations = {},
3636
$servers = {},
37+
$cron_success_command = '/bin/systemctl reload nginx.service',
3738
) {
3839
include nginx
3940
require ::letsencrypt

manifests/server.pp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@
3333
# Runs daily but only renews if near expiration, e.g. within 10 days.
3434
#
3535
define letsencrypt_nginx::server(
36-
$server = $name,
37-
$domains = undef,
38-
$exclude_domains = [],
39-
$webroot_paths = undef,
40-
$additional_args = undef,
41-
$manage_cron = true,
36+
$server = $name,
37+
$domains = undef,
38+
$exclude_domains = [],
39+
$webroot_paths = undef,
40+
$additional_args = undef,
41+
$manage_cron = true,
42+
$cron_success_command = undef
4243
){
4344
include letsencrypt_nginx
4445

46+
if $cron_success_command {
47+
$real_cron_success_command = $cron_success_command
48+
} else {
49+
$real_cron_success_command = $letsencrypt_nginx::cron_success_command
50+
}
51+
4552
if is_hash($::facts) {
4653
$firstrun_fact = $::facts['letsencrypt_nginx_firstrun']
4754
} else {
@@ -94,11 +101,12 @@
94101
# Always define letsencrypt::certonly with webroot for cronjob,
95102
# exec will not be executed again, if certificate exists
96103
letsencrypt::certonly{ $name:
97-
plugin => 'webroot',
98-
domains => $real_domains,
99-
webroot_paths => $real_webroot_paths,
100-
additional_args => $additional_args,
101-
manage_cron => $manage_cron,
102-
notify => Service['nginx'];
104+
plugin => 'webroot',
105+
domains => $real_domains,
106+
webroot_paths => $real_webroot_paths,
107+
additional_args => $additional_args,
108+
manage_cron => $manage_cron,
109+
cron_success_command => $real_cron_success_command,
110+
notify => Service['nginx'];
103111
}
104112
}

spec/defines/server_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class { ::letsencrypt:
147147
:notify => 'Service[nginx]',
148148
:manage_cron => true,
149149
:plugin => 'webroot',
150+
:cron_success_command => '/bin/systemctl reload nginx.service',
150151
)}
151152
end
152153
context "with firstrun_standalone mode success" do
@@ -186,6 +187,7 @@ class { ::letsencrypt:
186187
:domains => [ 'd1.foo.com', 'd2.bar.com'],
187188
:notify => 'Service[nginx]',
188189
:plugin => 'webroot',
190+
:cron_success_command => '/bin/systemctl reload nginx.service',
189191
)}
190192
end
191193
context "with firstrun_webroot " do
@@ -222,6 +224,7 @@ class { ::letsencrypt:
222224
:notify => 'Service[nginx]',
223225
:manage_cron => true,
224226
:plugin => 'webroot',
227+
:cron_success_command => '/bin/systemctl reload nginx.service',
225228
)}
226229
end
227230
context "with firstrun_webroot success" do
@@ -263,6 +266,7 @@ class { ::letsencrypt:
263266
:notify => 'Service[nginx]',
264267
:manage_cron => true,
265268
:plugin => 'webroot',
269+
:cron_success_command => '/bin/systemctl reload nginx.service',
266270
)}
267271
end
268272

0 commit comments

Comments
 (0)