Skip to content

Commit c602ae9

Browse files
author
Joshua Hoblitt
committed
fix notify pureftpd::service on config* classes from pureftpd class
1 parent 72dc2e6 commit c602ae9

File tree

2 files changed

+59
-8
lines changed

2 files changed

+59
-8
lines changed

manifests/init.pp

+8-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@
3535
$enable_ldap = { ldapconfigfile => $pureftpd::params::ldap_conf_path }
3636

3737
# instantiate a pureftpd::config::ldap that will notify the service class
38-
$safe_config_ldap = merge($config,
38+
$safe_config_ldap = merge($config_ldap,
3939
{ notify => Class[ 'pureftpd::service' ] }
4040
)
41-
create_resources( 'class', { 'pureftpd::config::ldap' => $config_ldap } )
41+
create_resources( 'class',
42+
{ 'pureftpd::config::ldap' => $safe_config_ldap }
43+
)
4244

4345
# only try to create the ldap configuration file after the pureftpd package
4446
# is installed and configuration; otherwise the dir may not exist yet
@@ -51,10 +53,12 @@
5153
$enable_pgsql = { pgsqlconfigfile => $pureftpd::params::pgsql_conf_path }
5254

5355
# instantiate a pureftpd::config::mysql will notify the service class
54-
$safe_config_pgsql = merge($config,
56+
$safe_config_pgsql = merge($config_pgsql,
5557
{ notify => Class[ 'pureftpd::service' ] }
5658
)
57-
create_resources( 'class', { 'pureftpd::config::pgsql' => $config_pgsql } )
59+
create_resources( 'class',
60+
{ 'pureftpd::config::pgsql' => $safe_config_pgsql }
61+
)
5862

5963
# only try to create the pgsql configuration file after the pureftpd
6064
# package is installed and configuration; otherwise the dir may not exist

spec/classes/pureftpd_spec.rb

+51-4
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@
128128
it do
129129
should include_class('pureftpd')
130130
should include_class('pureftpd::install')
131-
should include_class('pureftpd::config')
132-
should include_class('pureftpd::config::ldap')
131+
should contain_class('pureftpd::config') \
132+
.with_notify('Class[Pureftpd::Service]')
133+
should contain_class('pureftpd::config::ldap') \
134+
.with_notify('Class[Pureftpd::Service]')
133135
should include_class('pureftpd::service')
134136
should contain_package('pure-ftpd').with_ensure('present')
135137
should_not contain_package('pure-ftpd-selinux')
@@ -159,8 +161,10 @@
159161
it do
160162
should include_class('pureftpd')
161163
should include_class('pureftpd::install')
162-
should include_class('pureftpd::config')
163-
should include_class('pureftpd::config::pgsql')
164+
should contain_class('pureftpd::config') \
165+
.with_notify('Class[Pureftpd::Service]')
166+
should contain_class('pureftpd::config::pgsql') \
167+
.with_notify('Class[Pureftpd::Service]')
164168
should include_class('pureftpd::service')
165169
should contain_package('pure-ftpd').with_ensure('present')
166170
should_not contain_package('pure-ftpd-selinux')
@@ -180,4 +184,47 @@
180184
end
181185
end
182186

187+
describe 'with all config sections' do
188+
let(:params) {{
189+
:use_selinux => true,
190+
:config => {
191+
'ipv4only' => 'Yes',
192+
},
193+
:config_ldap => {
194+
'ldapserver' => 'ldap.example.com',
195+
},
196+
:config_pgsql => {
197+
'pgsqlserver' => 'localhost',
198+
}
199+
}}
200+
it do
201+
should include_class('pureftpd')
202+
should include_class('pureftpd::install')
203+
should contain_class('pureftpd::config') \
204+
.with_notify('Class[Pureftpd::Service]')
205+
should contain_class('pureftpd::config::ldap') \
206+
.with_notify('Class[Pureftpd::Service]')
207+
should contain_class('pureftpd::config::pgsql') \
208+
.with_notify('Class[Pureftpd::Service]')
209+
should include_class('pureftpd::service')
210+
should contain_package('pure-ftpd').with_ensure('present')
211+
should contain_package('pure-ftpd-selinux').with_ensure('present')
212+
should contain_file('/etc/pure-ftpd/pure-ftpd.conf').with_ensure('file') \
213+
.with_content(%r{PGSQLConfigFile /etc/pure-ftpd/pureftpd-pgsql.conf})\
214+
.with_content(%r{LDAPConfigFile /etc/pure-ftpd/pureftpd-ldap.conf})
215+
should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf').with_ensure('file') \
216+
.with_content(<<-END.gsub(/^\s+/, ""))
217+
LDAPServer ldap.example.com
218+
END
219+
should contain_file('/etc/pure-ftpd/pureftpd-pgsql.conf').with_ensure('file') \
220+
.with_content(<<-END.gsub(/^\s+/, ""))
221+
PGSQLServer localhost
222+
END
223+
should contain_service('pure-ftpd').with({
224+
'ensure' => 'running',
225+
'enable' => 'true',
226+
})
227+
end
228+
end
229+
183230
end

0 commit comments

Comments
 (0)