Simon Marechal
2013-May-25 06:20 UTC
[Puppet Users] "Future" parser and "return value" of resource definition
A simple example : file { ''/tmp/out'': content => [1,2,3,8].each |$v| { file { "/tmp/$v": content => $v; } } } Should it be valid to use "each" here ? If it is, what is the expected behavior (in my test the content of /tmp/out is ''3'') ? -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@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.
Simon Marechal
2013-May-25 07:53 UTC
[Puppet Users] Re: "Future" parser and "return value" of resource definition
Also, this is accepted : collect([1,2,3]) |$x| { file { "/tmp/b$x": content => collect([1,2,3]) |$y| { $y }; } } and this isn''t : collect([1,2,3]) |$x| { file { "/tmp/b$x": content => collect([1,2,3]) |$y| { $y + 0 }; } } Error: Failed to apply catalog: Parameter content failed on File[/tmp/b2]: Munging failed for value 1 in class content: can''t convert Fixnum into String at /etc/puppet/manifests/site.pp:4 but this is : each([1,2,3]) |$x| { file { "/tmp/ab$x": content => each([1,2,3]) |$y| { $y + 1 }; } } It also seems that "collect" isn''t too useful compared to "each" : * you can use collect everywhere you would use collect * "each" seems to return the original collection unchanged -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@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.
Simon Marechal
2013-May-26 16:04 UTC
[Puppet Users] Re: "Future" parser and "return value" of resource definition
On Saturday, May 25, 2013 9:53:37 AM UTC+2, Simon Marechal wrote:> > It also seems that "collect" isn''t too useful compared to "each" : > * you can use collect everywhere you would use collect > * "each" seems to return the original collection unchanged >Hum, that made no sense :) In my mind, there are two kinds of puppet functions : * functions at the statement level (realize, include, fail) * functions at the "value" level (fqdn_rand, file, etc.) : those functions either transform or produce data In the case of the "future" parser, it would be nice to either enforce this for each / collect (ie. use collect only in "value" context, and each in "statement" context), or to only have one function that does both. -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@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.