robert.gstoehl wrote:
I'd like to provide a definition with an argument which is optional
and defaults to the title:
net::route_default{"first": gateway => "192.168.0.1"}
or the shortcut:
net::route_default{"192.168.0.1"}
Do it like this:
define route_default($gateway="")
{
if $gateway == "" {
$xgateway = $title
} else {
$xgateway = $gateway
}
# Use $xgateway here instead of $gateway
}
define route_default($gateway=$title) {
exec {"echo $gateway >> /etc/defaultrouter":
unless => "grep $gateway /etc/defaultrouter"
}
...
Funny - puppet substitutes $title with the fully qualified hostname -
can someone shed some light on this one? :)
The default values for definition parameters are evaluated when the
definition is defined, not when the definition is used. And when
you are outside of definitions, $title is set to the node name.
/Bellman
--
You received this message because you are subscribed to the Google Groups "Puppet
Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.