Re: [Puppet Users] "Each" loop issue
Henrik, Didn't know about "Ask". I've added to the bookmarks for the next time ;) Thanks! 2014-07-04 10:53 GMT-03:00 Henrik Lindberg : > On 2014-04-07 14:59, Martin wrote: > >> Henrik, >> >> Thank you for such clear reply!.. I'll start debugging to find out what >> >> I'm missing here. >> >> I want to thank you for your support to the Puppet community, developing >> or taking the time to answer here in the list, your participation is >> really appreciated. >> In the other side, I think that documentation for the new parser is a >> bit poor. I've found more information googling around than in the >> official doc, and may be some questions in the list (as mine for ex) can >> be avoided with some improvements in the doc site. >> > > There will be new documentation for the new parser when it is released, as > Puppet 4.0.0. > > We have also been busy writing a specification of the language: > https://github.com/puppetlabs/puppet-specifications and we recently made > this w.i.p public. Please note that the specification is not finalized yet > so it cannot yet be considered authoritative. Also note that the spec is > not as user friendly as the regular documentation. > > > Also some >> troubleshooting guide would be awesome. >> >> Yeah, I would have loved to have had one - but for something like that > to be comprehensive it would be daunting to produce. Have you checked out > https://ask.puppetlabs.com/questions/ ? > > > - henrik > > -- > > Visit my Blog "Puppet on the Edge" > http://puppet-on-the-edge.blogspot.se/ > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Puppet Users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/puppet-users/ABTTFbVfr48/unsubscribe. > To unsubscribe from this group and all its topics, 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/lp6bk2%243rn%241%40ger.gmane.org. > > For more options, visit https://groups.google.com/d/optout. > -- 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/CAP0wnp81vz_Zzf33iba3yYh%3DPz_i3kjLF-i53GmS5CywaSni4g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] "Each" loop issue
On 2014-04-07 14:59, Martin wrote: Henrik, Thank you for such clear reply!.. I'll start debugging to find out what I'm missing here. I want to thank you for your support to the Puppet community, developing or taking the time to answer here in the list, your participation is really appreciated. In the other side, I think that documentation for the new parser is a bit poor. I've found more information googling around than in the official doc, and may be some questions in the list (as mine for ex) can be avoided with some improvements in the doc site. There will be new documentation for the new parser when it is released, as Puppet 4.0.0. We have also been busy writing a specification of the language: https://github.com/puppetlabs/puppet-specifications and we recently made this w.i.p public. Please note that the specification is not finalized yet so it cannot yet be considered authoritative. Also note that the spec is not as user friendly as the regular documentation. Also some troubleshooting guide would be awesome. Yeah, I would have loved to have had one - but for something like that to be comprehensive it would be daunting to produce. Have you checked out https://ask.puppetlabs.com/questions/ ? - henrik -- Visit my Blog "Puppet on the Edge" http://puppet-on-the-edge.blogspot.se/ -- 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/lp6bk2%243rn%241%40ger.gmane.org. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] "Each" loop issue
Henrik, Thank you for such clear reply!. I'll start debugging to find out what I'm missing here. I want to thank you for your support to the Puppet community, developing or taking the time to answer here in the list, your participation is really appreciated. In the other side, I think that documentation for the new parser is a bit poor. I've found more information googling around than in the official doc, and may be some questions in the list (as mine for ex) can be avoided with some improvements in the doc site. Also some troubleshooting guide would be awesome. Thanks again for all your hard work! Cheers, Martin 2014-07-03 23:01 GMT-03:00 Henrik Lindberg : > On 2014-03-07 23:00, martin.li...@gmail.com wrote: > >> Hi Ellison, >> >> That's right. That seems to be the case. >> I've been googling around, and seems that the new parser has a different >> scope from where it can grab the variables. Sadly, I can't find the way >> to make it work. >> Should I include something special in order to make the hiera variable >> available to the template? >> >> > There was a change to dynamic scoping - they were allowed when they should > not. That problem was fixed in the future parser branch of the logic. This > issue is PUP-1220. > > Not seeing your entire configuration it is hard to tell where the missing > variable is defined and if it should be visible or not. > If you can reference the variable at the point where you are making the > call to produce the template text, then something odd is going on. > > say doing something like: > > notice "The variable is set to: $the_var" > template(...) > > > - henrik > > -- > > Visit my Blog "Puppet on the Edge" > http://puppet-on-the-edge.blogspot.se/ > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Puppet Users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/puppet-users/ABTTFbVfr48/unsubscribe. > To unsubscribe from this group and all its topics, 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/lp51u5%24elo%241%40ger.gmane.org. > > For more options, visit https://groups.google.com/d/optout. > -- 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/CAP0wnp82AyTFZ6%2BaBDyHw_LmQTB-k%2BkSo%3DpsRw-ER9FDOmXMjQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] "Each" loop issue
On 2014-03-07 23:00, martin.li...@gmail.com wrote: Hi Ellison, That's right. That seems to be the case. I've been googling around, and seems that the new parser has a different scope from where it can grab the variables. Sadly, I can't find the way to make it work. Should I include something special in order to make the hiera variable available to the template? There was a change to dynamic scoping - they were allowed when they should not. That problem was fixed in the future parser branch of the logic. This issue is PUP-1220. Not seeing your entire configuration it is hard to tell where the missing variable is defined and if it should be visible or not. If you can reference the variable at the point where you are making the call to produce the template text, then something odd is going on. say doing something like: notice "The variable is set to: $the_var" template(...) - henrik -- Visit my Blog "Puppet on the Edge" http://puppet-on-the-edge.blogspot.se/ -- 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/lp51u5%24elo%241%40ger.gmane.org. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] "Each" loop issue
Hi Ellison, That's right. That seems to be the case. I've been googling around, and seems that the new parser has a different scope from where it can grab the variables. Sadly, I can't find the way to make it work. Should I include something special in order to make the hiera variable available to the template? Again, thanks for taking the time. Best regards, El jueves, 3 de julio de 2014 13:57:46 UTC-3, Ellison Marks escribió: > > That error means that the @server_roles variable is holding nil, as nil > does not have an each method to call. Perhaps the new parser is evaluating > things differently and not setting that variable. > > On Tuesday, July 1, 2014 5:25:15 PM UTC-7, martin...@gmail.com wrote: >> >> Henrik, Tristan, thanks for your replies! >> >> I've added "parser = future" on both master and agent, inside [main], and >> also I'm still using "--parser future", just in case. >> You both were right, and I'd use "notify" instead of "notice" in that >> snippet. >> >> I think that parser option is working now, but it's breaking a template >> that was working until now. So here I go again for your help, as I don't >> think that the parser should be doing this. >> >> Here is the output of the new error: >> >> *Error: Could not retrieve catalog from remote server: Error 400 on >> SERVER: Failed to parse template sudo/sudoers.erb:* >> * Filepath: >> /etc/puppet/environments/integration/modules/sudo/templates/sudoers.erb* >> * Line: 42* >> * Detail: undefined method `each' for nil:NilClass* >> * on node test01* >> >> Here is the line 42 of the template file: >> >> ... >> DEPLOY ALL = NOPASSWD: /usr/bin/service apache2 restart >> DEPLOY ALL = NOPASSWD: /usr/bin/service php5-fpm restart >> *<% @server_roles.each do |role| -%> <== line 42* >> <% if role == "testuser" %> >> DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 restart >> DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 start >> DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 stop >> <% end %> >> ... >> >> I've tried with "each @server_roles" too, but still broken. >> May be enabling the extra features of the parser, puppet tries to do >> something else with the word "each", but I'm totally lost here. >> >> Is this behavior expected? Is there any way that I can debug any deeper >> on this? >> >> Again, thanks in advance for any help. >> >> Cheers, >> >> Martin >> >> >> >> >> El martes, 1 de julio de 2014 12:27:16 UTC-3, Henrik Lindberg escribió: >>> >>> On 2014-30-06 23:58, martin...@gmail.com wrote: >>> > Hi Puppet users! >>> > >>> > I'm having an issue with "each loop" on puppet, and I just can't >>> figure >>> > out what am I doing wrong, so any help will be much appreciated. >>> > >>> > Here is my test.pp example: >>> > >>> > class mytestclass { >>> >$stuff = ["1", "2", "3"] >>> > >>> >each($stuff) |$x| { >>> > notice { $x: } >>> >>> You probably meant >>> >>> notify { $x: } >>> >>> notice is a logging function, and you can do >>> >>> notice $x >>> >>> >} >>> > } >>> >>> For this snippet to work, you must also do >>> >>> include mytestclass >>> >>> outside the scope of that class, otherwise nothing happens. >>> >>> > >>> > And here is the output when trying to apply it: /"Error: Could not >>> parse >>> > for environment production: Could not match |$x| at /tmp/test.pp:10"/ >>> > >>> Sounds like --parser future is not in effect. >>> >>> > I've "parser = future" inside my puppet.conf, ruby-rgen is installed >>> in >>> > both client and server. I'm also running it with "--parser future" on >>> > the client, but no joy. >>> > I've been playing with variants like "$stuff.each", using hashes, and >>> a >>> > few more desperate ideas. >>> > >>> > OS: Ubuntu 12.04 >>> > Puppet: 3.5.1-1puppetlabs1 >>> > ruby-rgen: 0.6.5-1puppetlabs1 >>> > >>> > >>> > I'm clearly missing something, but can't find what. >>> > >>> >>> As another poster suggested, maybe you have the parser=future setting in >>> the wrong section. >>> >>> Hope the above helps >>> >>> - henrik >>> >>> -- >>> >>> Visit my Blog "Puppet on the Edge" >>> http://puppet-on-the-edge.blogspot.se/ >>> >>> -- 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/384b92e8-9287-4685-a76f-e539ae7acf87%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] "Each" loop issue
That error means that the @server_roles variable is holding nil, as nil does not have an each method to call. Perhaps the new parser is evaluating things differently and not setting that variable. On Tuesday, July 1, 2014 5:25:15 PM UTC-7, martin...@gmail.com wrote: > > Henrik, Tristan, thanks for your replies! > > I've added "parser = future" on both master and agent, inside [main], and > also I'm still using "--parser future", just in case. > You both were right, and I'd use "notify" instead of "notice" in that > snippet. > > I think that parser option is working now, but it's breaking a template > that was working until now. So here I go again for your help, as I don't > think that the parser should be doing this. > > Here is the output of the new error: > > *Error: Could not retrieve catalog from remote server: Error 400 on > SERVER: Failed to parse template sudo/sudoers.erb:* > * Filepath: > /etc/puppet/environments/integration/modules/sudo/templates/sudoers.erb* > * Line: 42* > * Detail: undefined method `each' for nil:NilClass* > * on node test01* > > Here is the line 42 of the template file: > > ... > DEPLOY ALL = NOPASSWD: /usr/bin/service apache2 restart > DEPLOY ALL = NOPASSWD: /usr/bin/service php5-fpm restart > *<% @server_roles.each do |role| -%> <== line 42* > <% if role == "testuser" %> > DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 restart > DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 start > DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 stop > <% end %> > ... > > I've tried with "each @server_roles" too, but still broken. > May be enabling the extra features of the parser, puppet tries to do > something else with the word "each", but I'm totally lost here. > > Is this behavior expected? Is there any way that I can debug any deeper on > this? > > Again, thanks in advance for any help. > > Cheers, > > Martin > > > > > El martes, 1 de julio de 2014 12:27:16 UTC-3, Henrik Lindberg escribió: >> >> On 2014-30-06 23:58, martin...@gmail.com wrote: >> > Hi Puppet users! >> > >> > I'm having an issue with "each loop" on puppet, and I just can't figure >> > out what am I doing wrong, so any help will be much appreciated. >> > >> > Here is my test.pp example: >> > >> > class mytestclass { >> >$stuff = ["1", "2", "3"] >> > >> >each($stuff) |$x| { >> > notice { $x: } >> >> You probably meant >> >> notify { $x: } >> >> notice is a logging function, and you can do >> >> notice $x >> >> >} >> > } >> >> For this snippet to work, you must also do >> >> include mytestclass >> >> outside the scope of that class, otherwise nothing happens. >> >> > >> > And here is the output when trying to apply it: /"Error: Could not >> parse >> > for environment production: Could not match |$x| at /tmp/test.pp:10"/ >> > >> Sounds like --parser future is not in effect. >> >> > I've "parser = future" inside my puppet.conf, ruby-rgen is installed in >> > both client and server. I'm also running it with "--parser future" on >> > the client, but no joy. >> > I've been playing with variants like "$stuff.each", using hashes, and >> a >> > few more desperate ideas. >> > >> > OS: Ubuntu 12.04 >> > Puppet: 3.5.1-1puppetlabs1 >> > ruby-rgen: 0.6.5-1puppetlabs1 >> > >> > >> > I'm clearly missing something, but can't find what. >> > >> >> As another poster suggested, maybe you have the parser=future setting in >> the wrong section. >> >> Hope the above helps >> >> - henrik >> >> -- >> >> Visit my Blog "Puppet on the Edge" >> http://puppet-on-the-edge.blogspot.se/ >> >> -- 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/6e72c1a9-e6d9-4f88-92e9-9fb4d1624e53%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] "Each" loop issue
Henrik, Tristan, thanks for your replies! I've added "parser = future" on both master and agent, inside [main], and also I'm still using "--parser future", just in case. You both were right, and I'd use "notify" instead of "notice" in that snippet. I think that parser option is working now, but it's breaking a template that was working until now. So here I go again for your help, as I don't think that the parser should be doing this. Here is the output of the new error: *Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template sudo/sudoers.erb:* * Filepath: /etc/puppet/environments/integration/modules/sudo/templates/sudoers.erb* * Line: 42* * Detail: undefined method `each' for nil:NilClass* * on node test01* Here is the line 42 of the template file: ... DEPLOY ALL = NOPASSWD: /usr/bin/service apache2 restart DEPLOY ALL = NOPASSWD: /usr/bin/service php5-fpm restart *<% @server_roles.each do |role| -%> <== line 42* <% if role == "testuser" %> DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 restart DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 start DEPLOY ALL = NOPASSWD: /usr/bin/service tomcat7 stop <% end %> ... I've tried with "each @server_roles" too, but still broken. May be enabling the extra features of the parser, puppet tries to do something else with the word "each", but I'm totally lost here. Is this behavior expected? Is there any way that I can debug any deeper on this? Again, thanks in advance for any help. Cheers, Martin El martes, 1 de julio de 2014 12:27:16 UTC-3, Henrik Lindberg escribió: > > On 2014-30-06 23:58, martin...@gmail.com wrote: > > Hi Puppet users! > > > > I'm having an issue with "each loop" on puppet, and I just can't figure > > out what am I doing wrong, so any help will be much appreciated. > > > > Here is my test.pp example: > > > > class mytestclass { > >$stuff = ["1", "2", "3"] > > > >each($stuff) |$x| { > > notice { $x: } > > You probably meant > > notify { $x: } > > notice is a logging function, and you can do > > notice $x > > >} > > } > > For this snippet to work, you must also do > > include mytestclass > > outside the scope of that class, otherwise nothing happens. > > > > > And here is the output when trying to apply it: /"Error: Could not parse > > for environment production: Could not match |$x| at /tmp/test.pp:10"/ > > > Sounds like --parser future is not in effect. > > > I've "parser = future" inside my puppet.conf, ruby-rgen is installed in > > both client and server. I'm also running it with "--parser future" on > > the client, but no joy. > > I've been playing with variants like "$stuff.each", using hashes, and a > > few more desperate ideas. > > > > OS: Ubuntu 12.04 > > Puppet: 3.5.1-1puppetlabs1 > > ruby-rgen: 0.6.5-1puppetlabs1 > > > > > > I'm clearly missing something, but can't find what. > > > > As another poster suggested, maybe you have the parser=future setting in > the wrong section. > > Hope the above helps > > - henrik > > -- > > Visit my Blog "Puppet on the Edge" > http://puppet-on-the-edge.blogspot.se/ > > -- 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/0faae3f3-9b52-4984-b9d2-ce989518b633%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] "Each" loop issue
On 2014-30-06 23:58, martin.li...@gmail.com wrote: Hi Puppet users! I'm having an issue with "each loop" on puppet, and I just can't figure out what am I doing wrong, so any help will be much appreciated. Here is my test.pp example: class mytestclass { $stuff = ["1", "2", "3"] each($stuff) |$x| { notice { $x: } You probably meant notify { $x: } notice is a logging function, and you can do notice $x } } For this snippet to work, you must also do include mytestclass outside the scope of that class, otherwise nothing happens. And here is the output when trying to apply it: /"Error: Could not parse for environment production: Could not match |$x| at /tmp/test.pp:10"/ Sounds like --parser future is not in effect. I've "parser = future" inside my puppet.conf, ruby-rgen is installed in both client and server. I'm also running it with "--parser future" on the client, but no joy. I've been playing with variants like "$stuff.each", using hashes, and a few more desperate ideas. OS: Ubuntu 12.04 Puppet: 3.5.1-1puppetlabs1 ruby-rgen: 0.6.5-1puppetlabs1 I'm clearly missing something, but can't find what. As another poster suggested, maybe you have the parser=future setting in the wrong section. Hope the above helps - henrik -- Visit my Blog "Puppet on the Edge" http://puppet-on-the-edge.blogspot.se/ -- 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/loujvl%24vff%241%40ger.gmane.org. For more options, visit https://groups.google.com/d/optout.
[Puppet Users] "Each" loop issue
Hi Puppet users! I'm having an issue with "each loop" on puppet, and I just can't figure out what am I doing wrong, so any help will be much appreciated. Here is my test.pp example: class mytestclass { $stuff = ["1", "2", "3"] each($stuff) |$x| { notice { $x: } } } And here is the output when trying to apply it: *"Error: Could not parse for environment production: Could not match |$x| at /tmp/test.pp:10"* I've "parser = future" inside my puppet.conf, ruby-rgen is installed in both client and server. I'm also running it with "--parser future" on the client, but no joy. I've been playing with variants like "$stuff.each", using hashes, and a few more desperate ideas. OS: Ubuntu 12.04 Puppet: 3.5.1-1puppetlabs1 ruby-rgen: 0.6.5-1puppetlabs1 I'm clearly missing something, but can't find what. Any suggestion is welcomed! Cheers, Martin -- 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/452de1c9-83e1-4269-9a5b-40f4848b5d7f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.