File tree Expand file tree Collapse file tree 4 files changed +37
-16
lines changed Expand file tree Collapse file tree 4 files changed +37
-16
lines changed Original file line number Diff line number Diff line change 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 }
Original file line number Diff line number Diff line change 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 ;
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 }
Original file line number Diff line number Diff line change 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 )
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' ) }
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 )
Original file line number Diff line number Diff line change 11require 'spec_helper'
2+ require 'deep_merge'
23
34describe 'puppet' do
45 on_os_under_test . each do |os , facts |
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
You can’t perform that action at this time.
0 commit comments