On Tuesday, November 24, 2015 at 6:36:09 PM UTC-6, Matthew Ceroni wrote:
>
> I am having an issue accessing elements of a hash.
>
> First, it is defined in hiera as such:
>
> lb::rules:
>   VCC: rule1
>   GR: rule2
>
> I retrieve the value using
>
> $lb_rules = hiera('lb::rules')
>
> Then I simply try to print out one of the values
> ex:
>
>      notify { "$lb_rules[VCC]": }
>
> But get 
>
> Error 400 on SERVER: Evaluation Error: Missing title. The title expression 
> resulted in undef at 
> /etc/puppet/environments/sandbox/manifests/site.pp:14:11
>
> If I don't specify a key and instead do
>
> notify { "$lb_rules": }
>
> I get 
>
> Error 400 on SERVER: Evaluation Error: Illegal title type at index 0. 
> Expected String, got Hash[String, String]
>
> Confirming that lb_rules is a hash.
>
>

I've found that it's always a good idea to use the ${} form when you 
interpolate a value into a string.  Sometimes you don't actually need it, 
but sometimes you do, and it's just easier to do it all the time.  Thus,

notify { "${lb_rules[VCC]}": }

or, even better,

notify { "${lb_rules['VCC']}": }


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/5497c5f8-bf56-4cf0-92d6-a1f2d94ac536%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to