On Friday, 8 July 2016 04:27:26 UTC-4, Peter Faller wrote:
>
> Are you using the create_resources function to instantiate the resources?
> It takes a third argument containing default values:
>
> $widgets = hiera('widgets', {})
> $widget_defaults = hiera('widget_defaults', {})
> create_resources(::widget, $widgets, $widget_defaults)
>
I haven't go so far as to write that part yet, but I was thinking of
something along those lines. Because of the varying defaults, I would
actually need to iterate over the customer names.
$widgets = hiera('widgets', {})
$widget_defaults = hiera('widget_defaults', {})
$widgets.each |String $customer, Hash $data| { create_resources( ::widget,
$widgets[$customer], $widget_defaults[$customer] }
The problem I can't solve with this approach is that which customer's
widgets I'm creating is actually an important attribute of the widget type,
as it relates to where files get created, etc. This is why I was wondering
if there was a better way to organize the data in Hiera. I considered
reformatting the 'widgets' dictionary into a list so that the customer name
is an attribute, not a key:
$widgets = hiera('widgets', [])
$widget_defaults = hiera('widget_defaults', {})
$widget_defaults.each |String $customer, Hash $defaults| {
$widget_data = $widgets.filter |$data| { $data['customer'] == $customer }
create_resources( ::widget, $widget_data, $widget_defaults[$customer])
}
That gets repetitive and doesn't organize as well, however.
--
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/d822f840-5247-4d3e-ad9c-e6169fb4a273%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.