Skip to content

Commit 13b293b

Browse files
authored
Merge pull request #275 from nod0n/scripts
move scripts into a separate class
2 parents 0eaecd4 + 84f9150 commit 13b293b

File tree

6 files changed

+32
-19
lines changed

6 files changed

+32
-19
lines changed

REFERENCE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#### Private Classes
1919

2020
* `letsencrypt::config`: Configures the Let's Encrypt client.
21+
* `letsencrypt::scripts`: Deploy helper scripts scripts
2122

2223
### Defined types
2324

manifests/certonly.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@
141141
fail("The 'webroot_paths' parameter must be specified when using the 'webroot' plugin")
142142
}
143143

144+
include letsencrypt::scripts
145+
144146
# Wildcard-less title for use in file paths
145147
$title_nowc = regsubst($title, '^\*\.', '')
146148

@@ -252,7 +254,7 @@
252254
environment => $environment,
253255
provider => 'shell',
254256
require => [
255-
Class['letsencrypt'],
257+
Exec['initialize letsencrypt'],
256258
File['/usr/local/sbin/letsencrypt-domain-validation'],
257259
],
258260
}

manifests/init.pp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@
102102
refreshonly => true,
103103
}
104104

105-
# Used in letsencrypt::certonly Exec["letsencrypt certonly ${title}"]
106-
file { '/usr/local/sbin/letsencrypt-domain-validation':
107-
ensure => file,
108-
owner => 'root',
109-
group => 'root',
110-
mode => '0500',
111-
source => "puppet:///modules/${module_name}/domain-validation.sh",
112-
}
113-
114105
$certificates.each |$certificate, $properties| {
115106
letsencrypt::certonly { $certificate: * => $properties }
116107
}

manifests/scripts.pp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# @summary Deploy helper scripts scripts
2+
#
3+
# @api private
4+
#
5+
class letsencrypt::scripts () {
6+
assert_private()
7+
8+
# required in letsencrypt::certonly
9+
file { '/usr/local/sbin/letsencrypt-domain-validation':
10+
ensure => file,
11+
owner => 'root',
12+
group => 'root',
13+
mode => '0500',
14+
content => file("${module_name}/domain-validation.sh"),
15+
}
16+
}

spec/classes/letsencrypt_spec.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@
1919

2020
epel = facts[:osfamily] == 'RedHat' && facts[:operatingsystem] != 'Fedora'
2121

22-
it 'contains File[/usr/local/sbin/letsencrypt-domain-validation]' do
23-
is_expected.to contain_file('/usr/local/sbin/letsencrypt-domain-validation').
24-
with_ensure('file').
25-
with_owner('root').
26-
with_group('root').
27-
with_mode('0500').
28-
with_source('puppet:///modules/letsencrypt/domain-validation.sh')
29-
end
30-
3122
it 'contains the correct resources' do
3223
is_expected.to contain_class('letsencrypt::install').
3324
with(configure_epel: epel).
@@ -151,6 +142,7 @@
151142
} }
152143
end
153144

145+
it { is_expected.to compile.with_all_deps }
154146
it { is_expected.to contain_letsencrypt__certonly('foo').with_domains(%w[lth0edae4nzfq895 nsgqqm4mbw257t9i]) }
155147
it { is_expected.to contain_letsencrypt__certonly('a').with_environment(%w[ABC=y9jby5nmfgmstnbk DFE=y00lt0fh1vj2amjx]) }
156148
end

spec/defines/letsencrypt_certonly_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
it { is_expected.to compile.with_all_deps }
2121
it { is_expected.to contain_class('Letsencrypt::Install') }
2222
it { is_expected.to contain_class('Letsencrypt::Config') }
23+
it { is_expected.to contain_class('Letsencrypt::Scripts') }
24+
25+
# letsencrypt::scripts is a private class and is therefore tested in this define
26+
it 'contains the domain validation script' do
27+
is_expected.to contain_file('/usr/local/sbin/letsencrypt-domain-validation').
28+
with_ensure('file').
29+
with_owner('root').
30+
with_group('root').
31+
with_mode('0500').
32+
with_content(%r{#!/bin/sh})
33+
end
2334

2435
if facts[:osfamily] == 'FreeBSD'
2536
it { is_expected.to contain_file('/usr/local/etc/letsencrypt') }

0 commit comments

Comments
 (0)