Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to use a hash for the first time in puppet, so in my nodes.pp I'm going to use this:

node test1.example.com {
    netset::int::vconf {"servers" :
        label1 => { 'comment' => 'VIP Test1', 'ipaddress' => '192.168.1.10', 'netmask' => '255.255.255.0', 'int_label' => 'TEST1' },
        label2 => { 'comment' => 'VIP Test2', 'ipaddress' => '192.168.1.11', 'netmask' => '255.255.255.0', 'int_label' => 'TEST2' },
    }
}

In the file /etc/puppet/modules/netset/int/vconf.pp that I am writing I'm creating a defined type:

define netset::int::vconf ($comment,$ipaddress){...do somethings...}

My questionis how do I pass each keys of the hashes to the defined type? Somehow I'm imagining I'm going to have to create a loop somewhere, any help would be of great assistance.

Thanks Dan

share|improve this question

1 Answer 1

You are defining it in the wrong way, I believe.

If you have:

   define netset::int::vconf( $comment='', $ipaddress='' ) {
      .....
   }

then, you should define multiple instances with

   netset::int::vconf {
       label1: comment=>"comment1", ipaddress=>"192.168.1.1";
       label2: comment=>"comment2", ipaddress=>"192.168.2.2";
   }

Where label1 and label2 are the namevar. Note the trailing semicolon between defines.

share|improve this answer

Your Answer

 
discard

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.