Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a hash like so

net:ip { '':
ip => {
    ip1 => {
       addr => '',
       device => 'eth0',
    ip2 => {
      addr => '',
      device => 'eth10',

In my manifest I call like so

define net::ip (
) {

my question is how do I refer to the current loop of the hash iteration. I want to be able to use the "dev" field in this manifest, but since the hash has ip1,ip2 I can't tell what number its on?

Thanks Dan

share|improve this question
You're passing that hash to the defined type, but you're not showing us what's happening in that defined type; you'll need to clarify how exactly you're 'looping' over the hash - is it within an erb template? – Shane Madden Mar 13 '13 at 5:00
Apologies, thought that part wasn't relevant. Currently I am iterating over the loop in my erb template. But I need to access the device for each hash element inside the manifest. So really that's where my problem is. I understand that we can't do loops in manifests, but is there a way to get the device from a call? Thanks Dan – Dan Mar 13 '13 at 10:37

Following example may help. Create the hash separately and access it through a define type.

  $foo = [{"addr" => "bar", "port" => "1"},                                     
          {"addr" => "bat", "port" => "2"}]                                     
  testmod::bar {$foo:}                                                          
  define testmod::bar () {                                                      
    $var1 = $name["addr"]                                                       
    $var2 = $name["port"]                                                       
    notify {"${var1}_${var2}": }                                                
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.