Puppet external facts for Windows


Puppet external facts. What’s that? How to collect and manage them in a Windows environment? Probably, facts are one of the most crucial features of puppet. Think about facts as attributes to describe objects and components. Anything that can live in the environment being managed by puppet. This is certainly essential to collect them in order to be used later in puppet modules. In the Puppet docs You can find out more details about Puppet facts in general.

Puppet external facts examples

As puppet facts you may want to collect various data. Below I’ve listed several examples to be considered in every Windows environment.


All attributes specific to host, environment, etc.

Deployment status

In puppet sometimes it is required to store somewhere information about deployment status. This could be some kind of indicators showing true or false. Hence, the registry seems like one of the places where they can be stored in Windows environment. The facts can be used to collect that info. Later they will be available for puppet itself.

Installed / missing components

Not everything can be easily managed by puppet resources. Therefore, sometimes You will need to collect info about some installed components. Later you can reference it from puppet. As result puppet will be aware of any missing components.

Important services

Windows services that are not managed by puppet, but having dependencies on puppet modules, are good example of data to be collected. Especially service status is crucial info to be considered for facts collection.

Above is just an example of powershell script structure that could be used for Windows facts collection.

How to deploy and manage it

Since the facts usually varies across environments, it is good practice to maintain at least one facter script per environment. One way of achieving that is to store the powershell script in custom module as a template with various versions per environment. Here is a code snippet that You can use for ensuring that powershell script is deployed to the host. Later it will be used for external facts collection.


It was mentioned above to store facter powershell script in custom module as a template. The reason being is to enable hiera data usage. Hence, it can be part of Windows facts powershell script. As a result, you will end up with parametrized script controlled by very flexible mechanizm of hiera data. Here you can read more about hiera.


Leave a Reply