Ask Your Question
2

Retrive list from hiera

asked 2013-04-26 07:29:27 -0500

dawud gravatar image

Given the following module:

class clamav {

  package { $clamav::packages:
    ensure => installed,
  }
}

And the hierarchical data structure:

hiera.yaml:

---
:backends:
  - yaml
:hierarchy:
  - "%{::hostname}"
  - common
:yaml:
  :datadir: "/etc/puppet/hieradata/%{::domain}/%{::operatingsystem}"

common.yaml (snippet):

clamav::packages:
  - 'clamav-unofficial-sigs'
  - 'clamav-db'
  - 'clamav'
  - 'clamd'

In the puppetmaster node, I've checked that I can retrieve the data:

# hiera -a clamav::packages domain=my.company.com operatingsystem=CentOS
["clamav-unofficial-sigs", "clamav-db", "clamav", "clamd"]

However, puppet agent --test, despite compiling the catalog without errors, is failing with:

Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install undef' returned 1: Error: Nothing to do
Error: /Stage ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-04-26 08:04:16 -0500

llowder gravatar image

If you are using puppet3 and trying to make use of databindings, you need to change your code to:

class clamav (
  $packages,
){

  package { $packages:
    ensure => installed,
  }
}

If you want, you can provide a default set of pacakges or even just an empty array ($packages = [],).

If you are not using puppet 3, then add:

$packages = hiera('clamav::packages')

to the class. I would do that as the param still, so you can easily override it and will make the code easier to transition to puppet 3's databindings once you switch to puppet 3.

edit flag offensive delete link more

Comments

As a matter of fact, I have switched to puppet 3 already, and I was trying to use some of the new possibilities. One of the things I wanted to ...(more)

dawud gravatar imagedawud ( 2013-04-26 13:31:01 -0500 )edit

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

Stats

Asked: 2013-04-26 07:29:27 -0500

Seen: 2,479 times

Last updated: Apr 26 '13