create_resources and hiera

image_pdfimage_print

When using create_resources to instantiate defined resources with hiera, it is a good practice to include the last parameter to the create_resources function – the defaults parameter. The easiest thing is to set the default to an empty hash ‘{}’. If you don’t do this AND you don’t list the data item in hiera, you will see an error like:


Error: Could not find data item etc_host in any Hiera data file and no default supplied at /vagrant/dev_puppet/modules/hosts/manifests/hiera.pp:4 on node foo.foo.com

The fix is to set the default as an empty hash:

class hosts::hiera {

$etc_host = hiera('etc_host', {} )
create_resources('hosts::etchosts', $etc_host)

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments Protected by WP-SpamShield Spam Blocker