Hi,
there are some minor not-best-practices in your code:
1. create_resource
I prefer using lambda over create_resources as these allows explizit resource declaration which are then bound to the class.
This gives you explizit ordering, which you must add if using create_resource.
2. explizit lookups
you are doing explizit lookups. I prefer parameters using automatic databinding
3. accessing facts
Using $::factname is not the most modern way. Migrate to using facts hash (facts is a protected variable).
e.g. $facts['collect']
Your new code could be the following:
class mymodule (
Hash $external_http_domains, # not providing a default means that you must deliver data.
Optional[Hash] $internal_http_domains = undef, # if you want to allow undef values, you can set the data type to optional.
Hash $http_defaults,
){
if $facts['collect'] == 'external' {
$external_http_domain.each |$key, $value| {
nginx::resource::server { $key:
* => $value + $http_defaults,
}
}
} else {
$internal_http_domains.each |$key, $value| {
nginx::resource::server { $key:
* => $value + $http_defaults,
}
}
}
}
hth,
Martin
> --
> 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
puppet-users...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/1124d0d6-06b4-4ad5-9f06-a8a30fb9bbbfn%40googlegroups.com.