----- Original Message -----
> From: "Christopher Wood" <christopher_w...@pobox.com>
> To: "puppet-users" <puppet-users@googlegroups.com>
> Sent: Friday, 16 September, 2016 19:39:21
> Subject: Re: [Puppet Users] notify resource different between 3 and 4?

> On Fri, Sep 16, 2016 at 06:17:48PM +0100, R.I.Pienaar wrote:
>> 
>> 
>> ----- Original Message -----
>> > From: "Christopher Wood" <christopher_w...@pobox.com>
>> > To: "puppet-users" <puppet-users@googlegroups.com>
>> > Sent: Friday, 16 September, 2016 19:10:23
>> > Subject: [Puppet Users] notify resource different between 3 and 4?
>> 
>> > While trying to figure out the reduce function with notice/notify I 
>> > happened
>> > across this thing. It looks like an unquoted array in the notify resource's
>> > message only appears as its first array item. Not sure if it's a bug.
>> > 
>> > I couldn't find any documentation to say if this was intended and I 
>> > couldn't
>> > really tell what the type was doing with the self.should bit. I am not 
>> > actually
>> > a programmer.
>> > 
>> > $ cat /tmp/xx.pp
>> > $array = ["one", "two", "three"]
>> > 
>> > notify { 'notify one':
>> >  message => "${array}",
>> > }
>> > 
>> > notify { 'notify two':
>> >  message => $array,
>> > }
>> > 
>> 
>> yes this is across all resource types, you cant pass a array to the namevar 
>> and
>> produce many resources, you have to do so to the title
> 
> I thought both messages would have some variant of [one, two, three].
> 
> Also the namevar here is the name parameter.
> 
> But then things get even weirder when I try to do things with the namevar:
> 
> $ cat /tmp/y.pp
> $array = ["one", "two", "three"]
> 
> notify { $array:
>  message => $array,
> }
> 
> $ puppet apply /tmp/y.pp
> Notice: Compiled catalog for cwl.hostopia.com in environment production in 
> 0.04
> seconds
> Notice: one
> Notice: /Stage[main]/Main/Notify[one]/message: defined 'message' as 'one'
> Notice: one
> Notice: /Stage[main]/Main/Notify[two]/message: defined 'message' as 'one'
> Notice: one
> Notice: /Stage[main]/Main/Notify[three]/message: defined 'message' as 'one'
> Notice: Applied catalog in 0.08 seconds

kind of expected, or just undefined, message should be a string don't give it a 
array.
but you can see the names got created as per the array so that seems fine to 
me, if anything
I think it should raise when you pass non string to message


> But this seems like it might be more normal, but then breaks in a manner I did
> not expect:
> 
> $ cat /tmp/z.pp
> $array = ["one", "two", "three"]
> 
> notify { $array:
>  name => $array,
>  message => $array,
> }
> 
> $ puppet apply /tmp/z.pp
> Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot
> alias Notify[two] to [["one", "two", "three"]] at /tmp/z.pp:3; resource
> ["Notify", "one", "two", "three"] already declared at /tmp/z.pp:3 at
> /tmp/z.pp:3:1 on node cwl

yeah you cant pass arrays to name either - this is the main change here, you 
used to be able to.
It *is* though creating notify[one] notify[two] etc but then fail because of 
passing things
into name you shouldnt :)

> The namevar thing works as expected with a file. Feeling more like this is bug
> now.
>
> $ cat /tmp/a.pp
> $array = ["/tmp/one", "/tmp/two", "/tmp/three"]
> 
> file { $array:
>  content =>  $array,
> }

it doesnt really, content isnt the namevar. you're passing a array to title 
thats fine, content
being an array it's probably just going to puts the array into the file as a 
string

This stuff seems to work though errors can be a LOT better and I think it 
should be more strict
on the type of things passed to String properties like message

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/31059471.611617.1474047876604.JavaMail.zimbra%40devco.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to