Skip to content

Commit

Permalink
also chain private keys from puppet-certs correctly
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
evgeni committed May 5, 2022
1 parent 59e7f6a commit 9319a59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions manifests/plugin/remote_execution/mosquitto.pp
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@
File <| title == $ssl_cert |> ~> File["${mosquitto_ssl_dir}/ssl_cert.pem"]
File <| title == $ssl_key |> ~> File["${mosquitto_ssl_dir}/ssl_key.pem"]
File <| title == $ssl_ca |> ~> File["${mosquitto_ssl_dir}/ssl_ca.pem"]

if defined('private_key') {
Private_key <| title == $ssl_key |> ~> File["${mosquitto_ssl_dir}/ssl_key.pem"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,23 @@
end

it 'should notify mosquitto certs when source changes' do
should contain_file('/etc/foreman-proxy/ssl_cert.pem').with_notify(['File[/etc/mosquitto/ssl/ssl_cert.pem]'])
should contain_file('/etc/foreman-proxy/ssl_key.pem').with_notify(['File[/etc/mosquitto/ssl/ssl_key.pem]'])
should contain_file('/etc/foreman-proxy/ssl_ca.pem').with_notify(['File[/etc/mosquitto/ssl/ssl_ca.pem]'])
should contain_file('/etc/foreman-proxy/ssl_cert.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_cert.pem]')
should contain_file('/etc/foreman-proxy/ssl_key.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_key.pem]')
should contain_file('/etc/foreman-proxy/ssl_ca.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_ca.pem]')
end
end

describe 'with certs deployed by puppet as custom types' do
let(:pre_condition) do
<<-PUPPET
define private_key () { file { $name: ensure => file } }
private_key { '/etc/foreman-proxy/ssl_key.pem': }
PUPPET
end

it 'should notify mosquitto certs when source changes' do
should contain_private_key('/etc/foreman-proxy/ssl_key.pem').that_notifies('File[/etc/mosquitto/ssl/ssl_key.pem]')
end
end

Expand Down

0 comments on commit 9319a59

Please sign in to comment.