Forge Home

hiera_undef

Puppet hiera_undef module

35,077 downloads

17,783 latest version

3.1 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.1.17 (latest)
  • 1.1.16
  • 1.1.15
  • 1.1.14
  • 1.1.13
  • 1.1.12
  • 1.1.11
  • 1.1.10
  • 1.1.9
  • 1.1.8
  • 1.1.7
  • 1.1.6
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.0.0
released Aug 21st 2015
This version is compatible with:
  • Puppet Enterprise 3.x
  • Puppet 3.x
  • , ,
This module has been deprecated by its author since Feb 10th 2021.

The reason given was: No longer maintained/necessary

Start using this module

Tags: puppet, hiera, undef

Documentation

camptocamp/hiera_undef — version 1.1.17 Aug 21st 2015

Hiera-undef Puppet Module

Puppet Forge Build Status

This module is provided by Camptocamp

Why this module?

The hiera functions for Puppet are currently limited by the fact that Puppet functions cannot receive the undef value as it gets munged before the function receives it (see ticket #20923).

This module provides replacement functions that do not accept a default parameter, but use undef instead.

This module was written to ease the migration from Puppet 2.7 to 3.0, by writing wrapping classes using the hiera_undef() function. For example:

class wrapping::myapp {
  class { 'myapp':
    param1 => hiera_undef('myapp::param1'),
    param2 => hiera_undef('myapp::param2'),
  }
}

This approach allows to emulate data binding in Puppet 2.7 since:

  • the name of the variable passed to hiera_undef is of the form $class::$param, compatible with the way data bindings work;
  • if the variable is not found in Hiera, the function returns undef, and the class default is used, just like data bindings would do it.

The advantages of this approach are that:

  • only one level of wrapping classes is necessary (no turtles all the way down with global parameters);
  • it is compatible with both Puppet 2.X and 3.X;
  • the wrapping classes can safely be removed in Puppet 3.X as data binding will replace the calls to hiera_undef().

Example

A simple example might explain better than words. In the following examples, the foobar variable is not found in any Hiera backends in the current scope:

notify { 'test':
  message => hiera('foobar', undef),
}

returns:

Notice: 
Notice: /Stage[main]//Notify[test]/message: defined 'message' as ''

whereas:

notify { 'test':
  message => hiera_undef('foobar'),
}

returns:

Notice: test
Notice: /Stage[main]//Notify[test]/message: defined 'message' as 'test'

Contributing

Please report bugs and feature request using GitHub issue tracker.

For pull requests, it is very much appreciated to check your Puppet manifest with puppet-lint to follow the recommended Puppet style guidelines from the Puppet Labs style guide.

License

Copyright (c) 2013 puppet@camptocamp.com All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.