puppetlabs/puppetlabs-stdlib — pull request #38 by jeffmccune (2012-02-28 20:02:11+00:00)
Title: Puppet on Windows - stdlib module changes

This pull request SHOULD NOT BE MERGED YET. This is going to be a fairly long
running work in progress while I sort out the modules distributed with Puppet
Enterprise. I'm submitting this pull request early in the process in an effort
to get early feedback on the implementation decisions.

Please comment.

(#12357) Make facter_dot_d look in Puppet[:confdir]/facts.d

On Windows, we have no folders that match up to the default set of
directories the facter_dot_d fact looks in by default. This is a
problem because the Puppet Enterprise installer writes out the following
facts by default, and our modules require them to be present:

% cat /etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt
fact_stomp_port=61613
fact_stomp_server=puppetmaster
fact_is_puppetagent=true
fact_is_puppetmaster=true
fact_is_puppetconsole=true

On windows, the Puppet confdir is quite variable. On 2003 systems we
default to the All Users application data directory. On 2008 systems we
default to the ProgramData directory. The actual configuration
directory varies depending on the Puppet or Puppet Enterprise branding.

In order to simplify all of this variable behavior, this patch fixes the
problem by automatically looking for facts in Puppet[:confdir]/facts.d
There is no change in behavior if Puppet is not actually loaded into
memory.

This patch paves the way for the MSI installer to use an IniFile element
to write custom facts during installation. Since we're already writing
custom data into the puppet.conf file, and the 'facts.d' directory will
be a sub-folder of the folder containing puppet.conf, we'll be
reasonably guaranteed this implementation will be robust for all Windows
platforms that Puppet itself runs on.
(#12357) Fix root_home fact on Windows

Without this patch the root_home fact fails on windows. This patch
fixes the problem by implementing a code block confined to windows for
the fact's value resolution.

The implementation is as follows, looking entirely to the environment:

* Use %ProgramData% if it is set, otherwise...
* Use %LOCALAPPDATA% if it is set, otherwise...
* Use %TEMP% if it is set, otherwise...
* nil

There is no concept of a "home directory for the root user" on windows,
so we're defaulting to the closest thing we have available, the
%ProgramData% folder on modern windows operating systems.