Skip to content

Commit

Permalink
Merge pull request #259 from petems/MODULES-5953-add_stringify_facts_…
Browse files Browse the repository at this point in the history
…class_and_docs

(MODULES-5953) Adds ability to set stringify_facts
  • Loading branch information
MikaelSmith authored Nov 10, 2017
2 parents cb48507 + 760eca1 commit 74a2910
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ Note: this is the last release that will support Puppet 3 and Ruby <2.1.

Your agents must be running Puppet 3 with `stringify_facts` set to 'false', or Puppet 4+. Agents should already be pointed at a master running Puppet Server 2.1 or greater, and thus successfully applying catalogs compiled with the Puppet 4 language.

#### `stringify_facts` configuring

For 3.X machines, configuring the `stringify_facts` config settings can be done either with a dedicated Puppet class:

~~~puppet
include ::puppet_agent::prepare::stringify_facts
~~~

Or you can configure this with the [`puppet_conf`](https://forge.puppet.com/puppetlabs/puppet_conf) task module.

With [Puppet Enterprise Tasks](https://puppet.com/docs/pe/2017.3/orchestrator/puppet_tasks_overview.html):

~~~bash
puppet task run puppet_conf action=set section=main setting=stringify_facts value=false --nodes example-38-box.vm
~~~

With [bolt](https://puppet.com/docs/bolt/0.x/bolt.html) over SSH/WinRM:

~~~bash
bolt task run puppet_conf action=set section=main setting=stringify_facts value=false --nodes example-38-box.vm
~~~

Puppet 3.7 with future parser is required to compile this module, meaning it may be applied to masterless Puppet 3.7+, or earlier Puppet 3 agents connecting to a Puppet 3.7+ master.

### Beginning with puppet_agent
Expand Down Expand Up @@ -185,7 +207,7 @@ In addition, there are several known issues with Windows:
* MSI installation failures do not produce any error. If the install fails, puppet_agent continues to be applied to the agent. If this happens, you'll need to examine the MSI log file to determine the failure's cause. You can find the location of the log file in the debug output from either a puppet apply or an agent run; the log file name follows the pattern `puppet-<timestamp>-installer.log`.
* On Windows Server 2003, only x86 is supported, and the `arch` parameter is ignored. If you try to force an upgrade to x64, Puppet installs the x86 version with no error message.
* On Windows Server 2003 with Puppet Enterprise, the default download location is unreachable. You can work around this issue by specifying an alternate download URL in the `source` parameter.

Specifically in the 1.2.0 Release:
* For Windows, you must trigger an agent run after upgrading so that Puppet can create the necessary directory structures.

Expand Down
21 changes: 21 additions & 0 deletions manifests/prepare/stringify_facts.pp
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')
}

}
49 changes: 49 additions & 0 deletions spec/classes/puppet_agent_prepare_stringify_facts_spec.rb
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

0 comments on commit 74a2910

Please sign in to comment.