Skip to content

Puppet function for data-lookups based on a provided lookup-order

Notifications You must be signed in to change notification settings

glarizza/puppet-pick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The puppet-pick module

This module ONLY features a function named 'pick' that acts as data-lookup pattern in Puppet. For example, what if you wanted to define a parameter in the Puppet Enterprise Console (or Puppet Dashboard) that would be used as an override for a data lookup (like Hiera, for example). You would want to use the Console parameter if it existed, but fail-over to the Hiera lookup.

Use the function like the following:

  $result = pick($::console_parameter, hiera('hiera_parameter', 'default'))
  notify { "The resultant parameter value is: ${result}": }

The pick function would first look for a top-scope variable called 'console_parameter'. Because Console parameters become top-scope variables in Puppet, if a parameter called 'console_parameter' existed, the pick function would return that value. Failing that, it would do a Hiera lookup for a parameter called 'hiera_parameter'. Failing THAT, it would default to the value of 'default'. The above code assumes you had Hiera installed. If you wanted to failover to another variable, you could do the following:

  $result = pick($::console_parameter, $local_variable)
  notify { "The resultant parameter value is: ${result}": }

In this case, Puppet would fail over to the value in the variable called $local_variable

About

Puppet function for data-lookups based on a provided lookup-order

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages