On Thursday, September 19, 2013 1:12:22 PM UTC-5, Jeremiah Jester wrote:
>
>
> class log_special
> (
> #log_special::log_vars: "test"
> $log_vars=log_vars,
>
>
Note that Puppet 3's automatic data binding will result in the value
associated with key 'log_special::log_vars' being bound to parameter
$log_vars here. The default value will be used only if there is neither an
explicit binding via the class declaration nor a value obtainable from
hiera. The value will be obtained from hiera via the plain hiera()
function, but this will provide a hash if that's in fact the data type
present in the data.
> #log_special::log_vars2:
> # b: 'fdsa'
> # c: 'fdsaaaa'
> $log_vars2=hiera_hash('log_vars'),
>
That's ok, but of questionable utility. Also, only in those data-dependent
cases where hiera_hash() may return a different value than hiera() does is
it sensible. Those cases involve the value being present at multiple
levels in the data hierarchy.
> $log_vars2=$log_vars2['b']
>
That is broken, however. You cannot declare the same parameter name twice
(I'm surprised that Puppet does not diagnose it), plus, parameter default
values cannot safely refer to other parameters of the same class,
regardless of the order of the parameter list.
> )
> {
> exec{"log_vars": command=> "/bin/echo '${log_vars}'", logoutput=>true;}
> #Debug: Executing '/bin/echo 'test'
> exec{"log_vars2": command=> "/bin/echo '${log_vars2}'",
> logoutput=>true;}
> #Debug: Executing '/bin/echo 'bfdsacfdsaaaa''
>
>
And those are also at least somewhat broken, as interpolating a hash into a
string (the 'command' parameters) will cause it to be flattened.
Therefore, you cannot determine from the result whether the variable that
was interpolated was originally a string, or whether it was something
else. Supposing that you produced the output by declaring the class
something like this
class { 'log_special':
log_vars => 'test'
}
, and that the data are as you described in comments in your second post,
the output looks reasonable. I would say "looks as I would expect" if not
for the weird extra appearance of $log_vars2 among the class parameters.
John
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.