On Tuesday, November 4, 2014 9:16:55 AM UTC-6, duke wrote:
>
> Hi,
>
> While implementing custom facts in our environment I did some
> experimenting with structured
> facts in our Puppet manifests. Puppet is 3.7.2, Facter is 2.3.0, Master
> and Agent run on the
> same VM, future parser is on and stringify_facts is disabled.
>
> I failed at using one of my custom facts (an array of hashes) in Puppet
> manifests,
> so I did some tests with the "os" core fact and failed as well.
>
> To debug my manifest I added these two notice() calls
>
> notice($os[family])
> notice("$os[family]")
>
> and observed this output:
>
> : (Scope(Class[Dummy])) RedHat
> : (Scope(Class[Dummy])) {family => RedHat, name => CentOS, release =>
> {major => 6, minor => 5, full => 6.5}}[family]
>
> This is kinda weird, it seems as if Puppet fails to interpolate
> structured facts in double-quoted strings,
>
Well no, Puppet *is* interpolating. It is interpolating the string value
of the whole hash. What it is not doing is interpreting the index as an
index. Try this:
notice("${os[family]}")
I make it a general rule to *always* use braces around variable references
in quoted strings, even where not strictly necessary. It is harmless to do
so, and it saves having to determine on a case by case basis whether braces
are needed.
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 view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/636a5caf-5565-4791-a8e3-d79f69575341%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.