On Sep 2, 1:21 pm, Brad Krane <brad.kr...@gmail.com> wrote:
> Here is a very simple manifest that recreates this error:
>
> class foo {
>   define bar ( $val ) {
>     notice("bar($val)")
>   }
>
> }
>
> $some_hash = { 'name' => "some_name" }
>
> foo::bar { "$some_hash['name']": }
>
> Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid
> resource type foo::bar at /tmp/puptest.pp:9 on node www-cms-
> dev.fs.uwaterloo.ca
>
> This seems like a bug to me.


There is at minimum a documentation bug (the docs don't discuss
whether or how to interpolate hash values) and a bug / needed feature
regarding the extremely unhelpful error message.  I'm not sure whether
it's supposed to work to interpolate a hash value as you are
attempting to do (and I don't recall offhand whether you can
interpolate array elements either), but supporting that is at least a
viable feature request.

In the mean time, there are at least two workarounds I can think of.
One is to use an inline template to do your interpolation, and another
is to copy the hash value into an ordinary variable and then
interpolate that.  I would personally prefer the latter in most
circumstances; I find it clearer, especially if I need the hash value
more than once:

$theme_name = $theme['name']

# Site theme
drupal6::theme-repo { "${name}-${theme_name}":
}


Note also that there's a better solution for your simplified example,
where the string you want is exactly the hash value: just omit the
quotes.  To wit,

foo::bar { $some_hash['name']: }


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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to