Ask Your Question

Hiera not picking up packages resource

asked 2017-08-17 18:58:14 -0500

zroka gravatar image

Hi guys, I am experiencing with Puppet 4 and have the following issue: In my site.pp manifest i have defined the following default node:

   node default {
   include(hiera_array('classes', []))

In my common.yaml file i have entered the following:

  - motd
  - htop

The motd class is picked up just fine by my single node but the htop package does not.

But when I add the " htop " package resource to my site.pp it install no problem:

node default {
   include(hiera_array('classes', []))

   package { 'htop':
   ensure => 'present',

How can i make hiera install the package htop? I am using Puppet 4.10.6 Thanks

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2017-08-20 07:54:36 -0500

zroka gravatar image

I got this going with this set up in my site.pp

node default {

  hiera_include ('classes', [])

  $packages = hiera_hash('packages', {})
  create_resources('package', $packages)

  $services = hiera_hash('services', {})
  create_resources('service', $services)


All working good now as expected...

edit flag offensive delete link more

answered 2017-08-19 21:26:15 -0500

waveclaw gravatar image

A call to include classes by hiera will only include classes and their parameters.

Put your package resource into a class and then include that on your classes list in hiera.

Your class can take the list of packages as a parameter. That can then be looked up in hiera.

edit flag offensive delete link more

answered 2017-08-18 11:36:48 -0500

DarylW gravatar image

updated 2017-08-18 11:40:51 -0500

The include(hiera_array('classes', [])) call seems to be a different version of the hiera_include method, which uses the information from the 'classes' array in your hiera config to include them in your puppet code. There is no such mechanism that 'automatically' pulls in a package array from hiera. I'm not sure if there is a better way to do it in modern puppet (puppet4/5), but you can use the create_resources function to pass in an array of hashes representing the resources that you wish to create.

# A hash of user resources:
$myusers = {
  'nick' => { uid    => '1330',
              gid    => allstaff,
              groups => ['developers', 'operations', 'release'], },
  'dan'  => { uid    => '1308',
              gid    => allstaff,
              groups => ['developers', 'prosvc', 'release'], },

create_resources(user, $myusers)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-08-17 18:58:14 -0500

Seen: 26 times

Last updated: Aug 20