On Mon, 21 Feb 2011, Felix Frank wrote:
>
>
> On 02/19/2011 10:23 AM, Patrick wrote:
> > If so, you probably need to change the syntax in your define. I'm hoping
> > there's a syntax that tells puppet to join 2 arrays.
>
> If the provider in question fails to flatten the array properly, you're
> in trouble (this is true for the groups parameter of the user provider,
> for 0.25.5 at least).
>
> This is interesting and helpful:
> http://weblog.etherized.com/posts/175
Yeah, was trying originally to work out how to apply that. I don't know
whether this is the prettiest, but it works:
define append_aliases($other_aliases) {
$host_aliases += $other_aliases
host {
"$name.aao.gov.au":
ensure => $ensure,
ip => $ip,
host_aliases => $host_aliases,
}
}
define hostentry($ip, $hostaliases = [], $ensure = present) {
host {
$name:
ensure => absent,
}
$host_aliases = [ $name ]
append_aliases {
$name:
other_aliases => $hostaliases,
}
}
My original struggle was in working out how to initialise $host_aliases
in the caller to just $name, then appending the rest of the aliases.
Doing it the other way around was easy - I was just struggling with the
syntax and scoping. I would have liked to be able to reuse the parameter
name $host_aliases, but far too much juggling to get it around in the
right order to have host_aliases appended back onto something that ends up
being called host_aliases again.
--
Tim Connors
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.