Skip to content

Commit 9218b8f

Browse files
author
Benjamin Krein
committed
allow unsetting 'environment' with 'undef'
1 parent 0c15ebc commit 9218b8f

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

manifests/agent.pp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,22 @@
230230
value => $trusted_node_data,
231231
}
232232

233+
if $environment != undef
234+
{
235+
$environment_ensure = 'present'
236+
} else {
237+
$environment_ensure = 'absent'
238+
}
233239
ini_setting {'puppetagentenvironment':
234-
ensure => present,
240+
ensure => $environment_ensure,
235241
setting => 'environment',
236242
value => $environment,
237243
}
238244

239245
ini_setting {'puppetagentmaster':
240-
ensure => present,
241-
setting => 'server',
242-
value => $puppet_server,
246+
ensure => present,
247+
setting => 'server',
248+
value => $puppet_server,
243249
}
244250

245251
ini_setting {'puppetagentuse_srv_records':

spec/classes/puppet_agent_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,5 +574,25 @@
574574
)
575575
}
576576
end
577+
context 'with environment set to undef' do
578+
let(:params) do
579+
{
580+
:environment => 'undef',
581+
}
582+
end
583+
584+
it {
585+
should contain_ini_setting('puppetagentenvironment').with(
586+
:ensure => 'present',
587+
:section => 'agent',
588+
:path => '/etc/puppet/puppet.conf'
589+
)
590+
}
591+
it {
592+
should contain_ini_setting('puppetagentenvironment').without(
593+
:environment => 'production'
594+
)
595+
}
596+
end
577597
end
578598
end

0 commit comments

Comments
 (0)