On Friday, January 25, 2013 5:26:13 AM UTC-6, emzvargas
wrote:>
> Hello.
> I''m kind of new with puppet and i''mhaving a problem using
hashes with
> classes or defines.
> Here is an example of what im trying to do:
>
> $myhash = { key => "some value",
> other_key => "some other value",
> other_ki => "other other",
> }
>
> class test{
> file {"/var/tmp/$myhash[key]":
> ensure => "present",
> }
> }
>
> class {''test'':
> }
>
> Result:
> Error: Invalid tag "/var/tmp/other_keysome other valuekeysome
> valueother_kipepe" at /etc/puppet/manifests/site.pp:10 on nod
>
Puppet string interpolation does not recognize references to components of
compound values. Instead, you are getting interpolation of the whole hash
(coerced to a string). Do this instead:
class test{
$value = $myhash[''key'']
file {"/var/tmp/$value":
ensure => "present",
}
}
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.