0

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

Dan
  • 357
  • 3
  • 4
  • 16

1 Answers1

0

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.

Steve Shipway
  • 742
  • 5
  • 17