I'm with Andy on this one... I'm doing something very similar with my NetApp volume provider (
https://github.com/fatmcgav/fatmcgav-netapp/).
I've created a define with the following contents:
define util::netapp::volume (
$ensure = present,
$size,
$aggr = 'aggr1',
$snapresv = 0,
$autoincrement = true,
$snapschedule = {"minutes" => 0, "hours" => 0, "days" => 0, "weeks" => 0}
) {
netapp_notify {"volume_define_${name}":
message => "Processing Volume ${name}",
}
->
netapp_volume { "v_${name}":
ensure => $ensure,
initsize => $size,
aggregate => $aggr,
spaceres => "none",
snapreserve => $snapresv,
autoincrement => $autoincrement,
options => {'convert_ucode' => 'on', 'no_atime_update' => 'on', 'try_first' => 'volume_grow'},
snapschedule => $snapschedule
}
->
netapp_qtree { "q_${name}":
ensure => $ensure,
volume => "v_${name}"
}
->
netapp_export { "/vol/v_${name}/q_${name}":
ensure => $ensure,
persistent => true
}
}
I've added a default hash to 'snapschedule' in the options list, but that can be over-ridden from the Hiera data.
Then use the following to pull the data from hiera and call the define:
create_resources( util::netapp::volume, hiera('volumes') )
'Volumes' in hiera yaml looks like:
volumes:
vol1:
ensure: present
size: '500m'
vol2:
ensure: present
size: '20g'
snapschedule:
minutes: 0
hours: 36
days: 0
weeks: 0
You can also use the 'hiera' command to test your yaml structure:
$ hiera -c hiera.yaml volumes clientcert=act-star-nactl01
{"vol1"=>{"ensure"=>"present", "size"=>"500m"}, "vol2"=>{"ensure"=>"present", "size"=>"20g", "snapschedule"=>{"days"=>0, "weeks"=>0, "hours"=>36, "minutes"=>0}}}
As you can see from the above output,
snapschedule for
vol2 is a nested hash. This assumes that your resource provider can support hashes on the relevant param/property ;)
HTH
Gav