-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from petems/MODULES-5953-add_stringify_facts_…
…class_and_docs (MODULES-5953) Adds ability to set stringify_facts
- Loading branch information
Showing
3 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# == Class puppet_agent::prepare::stringify_facts | ||
# | ||
# A preperation class to configure the stringify_facts setting to false | ||
# | ||
class puppet_agent::prepare::stringify_facts { | ||
|
||
if (versioncmp($::clientversion, '4.0.0') < 0) { | ||
|
||
ini_setting { 'puppet stringify_facts': | ||
ensure => present, | ||
path => $::puppet_config, | ||
section => 'main', | ||
setting => 'stringify_facts', | ||
value => false, | ||
} | ||
|
||
} else { | ||
warning('The puppet_agent::prepare::stringify_facts class should only be run on Puppet < 4') | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper' | ||
|
||
describe 'puppet_agent::prepare::stringify_facts' do | ||
context 'supported operating system families' do | ||
%w[Debian RedHat SuSE].each do |osfamily| | ||
case osfamily | ||
when 'SuSE' | ||
os = 'SLES' | ||
osmajor = '10' | ||
else | ||
os = 'foo' | ||
osmajor = '42' | ||
end | ||
|
||
facts = { | ||
operatingsystem: os, | ||
operatingsystemmajrelease: osmajor, | ||
architecture: 'bar', | ||
osfamily: osfamily, | ||
lsbdistid: osfamily, | ||
lsbdistcodename: 'baz', | ||
mco_server_config: nil, | ||
mco_client_config: nil | ||
} | ||
|
||
context "on #{osfamily}" do | ||
if Puppet.version < '4.0.0' | ||
context 'on Puppet 3 or lower' do | ||
it { | ||
is_expected.to contain_ini_setting('puppet stringify_facts').with( | ||
ensure: 'present', | ||
value: false | ||
) | ||
} | ||
end | ||
else | ||
context 'on Puppet 4 or higher' do | ||
it { | ||
is_expected.to_not contain_ini_setting('puppet stringify_facts').with( | ||
ensure: 'present', | ||
value: false | ||
) | ||
} | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |