Skip to content

Commit e8c133e

Browse files
baurmattekohl
authored andcommitted
Move client_certname to [main]
This is needed to ensure all Puppet subcommands can properly use it.
1 parent 27eb207 commit e8c133e

File tree

4 files changed

+37
-16
lines changed

4 files changed

+37
-16
lines changed

manifests/agent/config.pp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
'postrun_command': value => $::puppet::postrun_command;
3232
}
3333
}
34-
if $::puppet::client_certname {
35-
puppet::config::agent {
36-
'certname': value => $::puppet::client_certname;
37-
}
38-
}
3934

4035
$::puppet::agent_additional_settings.each |$key,$value| {
4136
puppet::config::agent { $key: value => $value }

manifests/config.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
$srv_domain = $::puppet::srv_domain,
1818
$use_srv_records = $::puppet::use_srv_records,
1919
$additional_settings = $::puppet::additional_settings,
20+
$client_certname = $::puppet::client_certname,
2021
) {
2122
puppet::config::main{
2223
'vardir': value => $::puppet::vardir;
@@ -63,6 +64,11 @@
6364
if $syslogfacility and !empty($syslogfacility) {
6465
puppet::config::main{'syslogfacility': value => $syslogfacility; }
6566
}
67+
if $client_certname {
68+
puppet::config::main {
69+
'certname': value => $client_certname;
70+
}
71+
}
6672

6773
$additional_settings.each |$key,$value| {
6874
puppet::config::main { $key: value => $value }

spec/classes/puppet_agent_spec.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
let :facts do
3333
facts.deep_merge(
34-
# rspec-puppet(-facts) doesn't mock this
35-
clientcert: 'client.example.com',
3634
# Cron/systemd timers are based on the IP - make it consistent
3735
networking: { ip: '192.0.2.100' }
3836
)
@@ -73,7 +71,6 @@
7371
it { is_expected.to contain_file(confdir).with_ensure('directory') }
7472
it { is_expected.to contain_concat("#{confdir}/puppet.conf") }
7573
it { is_expected.to contain_concat__fragment('puppet.conf_agent').with_content(/^\[agent\]/) }
76-
it { is_expected.to contain_puppet__config__agent('certname').with_value(facts[:clientcert]) }
7774
it { is_expected.to contain_puppet__config__agent('report').with_value('true') }
7875
it { is_expected.not_to contain_puppet__config__agent('prerun_command') }
7976
it { is_expected.not_to contain_puppet__config__agent('postrun_command') }
@@ -351,14 +348,6 @@
351348
it { should_not contain_file('/var/lib/puppet/state/agent_disabled.lock') }
352349
end
353350

354-
context 'with client_certname => false' do
355-
let :params do
356-
super().merge(client_certname: false)
357-
end
358-
359-
it { is_expected.not_to contain_puppet__config__agent('certname') }
360-
end
361-
362351
context 'with report => false' do
363352
let :params do
364353
super().merge(report: false)

spec/classes/puppet_config_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper'
2+
require 'deep_merge'
23

34
describe 'puppet' do
45
on_os_under_test.each do |os, facts|
@@ -132,6 +133,36 @@
132133
end
133134
end
134135

136+
describe 'client_certname' do
137+
context 'with client_certname => $::clientcert' do
138+
let :facts do
139+
# rspec-puppet(-facts) doesn't mock this
140+
facts.deep_merge(clientcert: 'client.example.com')
141+
end
142+
let :params do
143+
super().merge(client_certname: facts[:clientcert])
144+
end
145+
146+
it { is_expected.to contain_puppet__config__main('certname').with_value(facts[:clientcert]) }
147+
end
148+
149+
context 'with client_certname => "foobar"' do
150+
let :params do
151+
super().merge(client_certname: 'foobar')
152+
end
153+
154+
it { is_expected.to contain_puppet__config__main('certname').with_value('foobar') }
155+
end
156+
157+
context 'with client_certname => false' do
158+
let :params do
159+
super().merge(client_certname: false)
160+
end
161+
162+
it { is_expected.not_to contain_puppet__config__main('certname') }
163+
end
164+
end
165+
135166
context 'puppetmaster' do
136167
describe "when puppetmaster => 'mymaster.example.com'" do
137168
let :params do

0 commit comments

Comments
 (0)