Skip to content

Commit 9319a59

Browse files
committed
also chain private keys from puppet-certs correctly
the problem is that `ssl_key.pem` in a Katello deployment is a `private_key` from the `certs` module, and while that *does* define a `file` internally (https://github.com/theforeman/puppet-certs/blob/5ce5b4b9e8a13a7a630cc607ecfa5e48991a2aa9/lib/puppet/type/private_key.rb#L64) those are not available for matching of a collector. https://puppet.com/docs/puppet/6/lang_collectors.html: > Collectors can search only on attributes that are present in the manifests (the `file` resource is not in the manifest, the `private_key` is)
1 parent 59e7f6a commit 9319a59

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

manifests/plugin/remote_execution/mosquitto.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,8 @@
9797
File <| title == $ssl_cert |> ~> File["${mosquitto_ssl_dir}/ssl_cert.pem"]
9898
File <| title == $ssl_key |> ~> File["${mosquitto_ssl_dir}/ssl_key.pem"]
9999
File <| title == $ssl_ca |> ~> File["${mosquitto_ssl_dir}/ssl_ca.pem"]
100+
101+
if defined('private_key') {
102+
Private_key <| title == $ssl_key |> ~> File["${mosquitto_ssl_dir}/ssl_key.pem"]
103+
}
100104
}

spec/classes/foreman_proxy__plugin__remote_execution__mosquitto_spec.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,23 @@
9999
end
100100

101101
it 'should notify mosquitto certs when source changes' do
102-
should contain_file('/etc/foreman-proxy/ssl_cert.pem').with_notify(['File[/etc/mosquitto/ssl/ssl_cert.pem]'])
103-
should contain_file('/etc/foreman-proxy/ssl_key.pem').with_notify(['File[/etc/mosquitto/ssl/ssl_key.pem]'])
104-
should contain_file('/etc/foreman-proxy/ssl_ca.pem').with_notify(['File[/etc/mosquitto/ssl/ssl_ca.pem]'])
102+
should contain_file('/etc/foreman-proxy/ssl_cert.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_cert.pem]')
103+
should contain_file('/etc/foreman-proxy/ssl_key.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_key.pem]')
104+
should contain_file('/etc/foreman-proxy/ssl_ca.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_ca.pem]')
105+
end
106+
end
107+
108+
describe 'with certs deployed by puppet as custom types' do
109+
let(:pre_condition) do
110+
<<-PUPPET
111+
define private_key () { file { $name: ensure => file } }
112+
113+
private_key { '/etc/foreman-proxy/ssl_key.pem': }
114+
PUPPET
115+
end
116+
117+
it 'should notify mosquitto certs when source changes' do
118+
should contain_private_key('/etc/foreman-proxy/ssl_key.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_key.pem]')
105119
end
106120
end
107121

0 commit comments

Comments
 (0)