Your other option if using the future parser is to use the each function 
and iterate around the hash like you would in any other language.

$interfaces = hiera('network_interfaces')

# https://docs.puppetlabs.com/references/latest/function.html#each


$interfaces.each { |$interface|
  managed_interface { $interface['device']:
    device  => $interface['name'],
    ipaddr  => $interface['ipaddr'],
    netmask => $interface['netmask'], 
  }
}


Corey

On Tuesday, October 14, 2014 2:29:35 AM UTC-7, Andreas Dvorak wrote:
>
> Hi,
>
> I would like to create network interfaces with puppet.
> I have
> define network_interface::managed_interface(
>   $device='',
>   $gateway='',
>   $hostname='',
>   $hwaddr='',
>   $ipaddr='',
>   $netmask='',
>   $network='',
>   $up=true,
> ){
>
> and
> class network_interface::create_interface (
>   $device = hiera(....)',
> ){
>   managed_interface { $device:
>     device  => $device,
>     ipaddr  => $ipaddr,
>     netmask => $netmask, 
>   }
> }
>
> and hiera yaml file:
> network_interface:
>   eth0:
>     ipaddr: 10.112.67.40
>     netmask: 255.255.0.0
>   eth1:
>     ipaddr: 10.15.67.40
>     netmask: 255.255.0.0
>
> Now I don't know how to read the hiera values in the class 
> network_interface::create_interface. The interface names can be different.
> Can some please help me?
>
> Best regards
> Andreas
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20d0e3e3-3b97-4276-a231-b2f1ce30a2b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to