Will something like this work in a template? <% if fqdn.starts_with?''something'' then %> My test isn''t working, I don''t know if it''s some minor syntax issue or if I''m completely out of bounds. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
you might want to try regexp, e.g. <% if fqdn =~ /^something/ -%> I would say that its usually not a good idea to have if conditions in your manifest or templates based on hostnames.. Ohad On Thu, Mar 4, 2010 at 10:01 PM, Len Rugen <lenrugen@gmail.com> wrote:> Will something like this work in a template? > > <% if fqdn.starts_with?''something'' then %> > > My test isn''t working, I don''t know if it''s some minor syntax issue or if > I''m completely out of bounds. > > -- > 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+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Len Rugen wrote:> Will something like this work in a template? > > <% if fqdn.starts_with?''something'' then %> > > My test isn''t working, I don''t know if it''s some minor syntax issue or > if I''m completely out of bounds. > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en.Looks like starts_with isn''t a method: irb(main):002:0> fqdn = "something.somesite.com" => "something.somesite.com" irb(main):003:0> fqdn.starts_with?''some'' NoMethodError: undefined method `starts_with?'' for "something.somesite.com":String If you don''t have irb I suggest installing it, it''s pretty useful for testing this kind of stuff. I forget if there is a substring method like starts_with, but you can do regex matching: irb(main):004:0> if fqdn =~ /^some/ irb(main):005:1> puts "yea" irb(main):006:1> end yea => nil -- Joe McDonagh AIM: YoosingYoonickz IRC: joe-mac on freenode L''ennui est contre-révolutionnaire -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Mar 4, 2010 at 2:01 PM, Len Rugen <lenrugen@gmail.com> wrote:> Will something like this work in a template? > > <% if fqdn.starts_with?''something'' then %>Try ''start_with?'' instead of ''starts_with?'' -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thanks! That one works with only a warning: warning: parenthesize argument(s) for future version but I can''t figure out where it would like parens. This is the problem with web/wiki doc, you never know if it''s REALLY right. I couldn''t get any regex option working in a template either, but then, I don''t know regex. It seems I''m presented with 2-3 new things a week that I''m supposed to fully understand and know the syntax in full detail. It''s not going to happen.... Now back to something called maven...... -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Len Rugen wrote:> Thanks! That one works with only a warning: > warning: parenthesize argument(s) for future version > > but I can''t figure out where it would like parens. > > This is the problem with web/wiki doc, you never know if it''s REALLY > right. I couldn''t get any regex option working in a template either, > but then, I don''t know regex.That (regex in a template) is a function of ruby, and probably a slight syntactic issue, like putting the tilde on the wrong side of the equals sign, forgetting to encapsulate your regex in //, etc.> > It seems I''m presented with 2-3 new things a week that I''m supposed to > fully understand and know the syntax in full detail. It''s not going > to happen....If you''re in the infrastructure business, sounds like par for the course. This is why we make the big bucks. As far as the docs go, you may just be on an older version of puppet. Running ''puppetdoc'' with no arguments will spit out docs for the running version on your system.> > Now back to something called maven...... > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en.-- Joe McDonagh AIM: YoosingYoonickz IRC: joe-mac on freenode L''ennui est contre-révolutionnaire -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Well, it workes in erb test, but not when puppet runs: undefined method `start_with?'' for.... via puppet erb -x -T ''-'' test.erb | ruby -c says Syntax OK.... On Thu, Mar 4, 2010 at 10:40 AM, Len Rugen <lenrugen@gmail.com> wrote:> Thanks! That one works with only a warning: > warning: parenthesize argument(s) for future version > > but I can''t figure out where it would like parens. > > This is the problem with web/wiki doc, you never know if it''s REALLY > right. I couldn''t get any regex option working in a template either, but > then, I don''t know regex. > > It seems I''m presented with 2-3 new things a week that I''m supposed to > fully understand and know the syntax in full detail. It''s not going to > happen.... > > Now back to something called maven...... > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Mar 4, 2010 at 9:01 AM, Len Rugen <lenrugen@gmail.com> wrote:> Well, it workes in erb test, but not when puppet runs: > > undefined method `start_with?'' for.... via puppet > > erb -x -T ''-'' test.erb | ruby -c says Syntax OK....I thought ''start_with" was a ruby 1.9 thing only? And "starts_with" is a Rails-ism ?> > > > On Thu, Mar 4, 2010 at 10:40 AM, Len Rugen <lenrugen@gmail.com> wrote: >> >> Thanks! That one works with only a warning: >> warning: parenthesize argument(s) for future version >> >> but I can''t figure out where it would like parens. >> >> This is the problem with web/wiki doc, you never know if it''s REALLY >> right. I couldn''t get any regex option working in a template either, but >> then, I don''t know regex. >> >> It seems I''m presented with 2-3 new things a week that I''m supposed to >> fully understand and know the syntax in full detail. It''s not going to >> happen.... >> >> Now back to something called maven...... >> > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- nigel -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1>> Well, it workes in erb test, but not when puppet runs: >> >> undefined method `start_with?'' for.... via puppet >> >> erb -x -T ''-'' test.erb | ruby -c says Syntax OK.... > > I thought ''start_with" was a ruby 1.9 thing only? And "starts_with" is > a Rails-ism ?exactly. cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkuP8TwACgkQbwltcAfKi3+ghwCfTT1ThE2ar9tHrKPH5repB1kl giIAn2cTfuBUukTtOhTGRxyruif1Vf7y =YkSL -----END PGP SIGNATURE----- -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
We''re running ruby 1.8.5, which is current on the RHEL channel. Are others running puppet at 1.9? -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> We''re running ruby 1.8.5, which is current on the RHEL channel. Are others > running puppet at 1.9?I don''t think that puppet is yet fully supported on 1.9, so I don''t assume it. Hence you should go with the RegExp. cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkuQDA0ACgkQbwltcAfKi3+OnQCgtjYJ73n/QOonSrfNf6i48WHJ TRIAnA4tN1BMJFqiNqEmyMn+KY2zSTjk =5Htb -----END PGP SIGNATURE----- -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
So can someone point to working regex template example? Thanks On Thu, Mar 4, 2010 at 1:37 PM, Peter Meier <peter.meier@immerda.ch> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > We''re running ruby 1.8.5, which is current on the RHEL channel. Are > others > > running puppet at 1.9? > > I don''t think that puppet is yet fully supported on 1.9, so I don''t > assume it. Hence you should go with the RegExp. > > cheers pete > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkuQDA0ACgkQbwltcAfKi3+OnQCgtjYJ73n/QOonSrfNf6i48WHJ > TRIAnA4tN1BMJFqiNqEmyMn+KY2zSTjk > =5Htb > -----END PGP SIGNATURE----- > > -- > 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+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> So can someone point to working regex template example?First answer of Ohad to your question:> you might want to try regexp, e.g. > > <% if fqdn =~ /^something/ -%>irb(main):001:0> "aaaa" =~ /^aa/ => 0 irb(main):002:0> "aaaa" =~ /^ab/ => nil =~ returns the first location of the occurence of the pattern or nil if none is found. if nil in ruby will never be evaluated. cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkuQr9sACgkQbwltcAfKi39wRgCeJtTVbOFcRC4I3TWQFm2YTWOk mskAni20CwM2zvqarbhyKcQNC9cznNAL =mAAm -----END PGP SIGNATURE----- -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
But they don''t seem to work IN A TEMPLATE.... On Fri, Mar 5, 2010 at 1:16 AM, Peter Meier <peter.meier@immerda.ch> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > So can someone point to working regex template example? > > First answer of Ohad to your question: > > > you might want to try regexp, e.g. > > > > <% if fqdn =~ /^something/ -%> > > > irb(main):001:0> "aaaa" =~ /^aa/ > => 0 > irb(main):002:0> "aaaa" =~ /^ab/ > => nil > > =~ returns the first location of the occurence of the pattern or nil if > none is found. if nil in ruby will never be evaluated. > > cheers pete > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkuQr9sACgkQbwltcAfKi39wRgCeJtTVbOFcRC4I3TWQFm2YTWOk > mskAni20CwM2zvqarbhyKcQNC9cznNAL > =mAAm > -----END PGP SIGNATURE----- > > -- > 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+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Maybe the dash in -%> is the problem, I was tunnel visioned on the regex part. On Fri, Mar 5, 2010 at 6:58 AM, Len Rugen <lenrugen@gmail.com> wrote:> But they don''t seem to work IN A TEMPLATE.... > > On Fri, Mar 5, 2010 at 1:16 AM, Peter Meier <peter.meier@immerda.ch>wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> > So can someone point to working regex template example? >> >> First answer of Ohad to your question: >> >> > you might want to try regexp, e.g. >> > >> > <% if fqdn =~ /^something/ -%> >> >> >> irb(main):001:0> "aaaa" =~ /^aa/ >> => 0 >> irb(main):002:0> "aaaa" =~ /^ab/ >> => nil >> >> =~ returns the first location of the occurence of the pattern or nil if >> none is found. if nil in ruby will never be evaluated. >> >> cheers pete >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.9 (GNU/Linux) >> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org >> >> iEYEARECAAYFAkuQr9sACgkQbwltcAfKi39wRgCeJtTVbOFcRC4I3TWQFm2YTWOk >> mskAni20CwM2zvqarbhyKcQNC9cznNAL >> =mAAm >> -----END PGP SIGNATURE----- >> >> -- >> 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+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Mar 4, 2010 at 5:43 PM, Peter Meier <peter.meier@immerda.ch> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > >>> Well, it workes in erb test, but not when puppet runs: >>> >>> undefined method `start_with?'' for.... via puppet >>> >>> erb -x -T ''-'' test.erb | ruby -c says Syntax OK.... >> >> I thought ''start_with" was a ruby 1.9 thing only? And "starts_with" is >> a Rails-ism ? > > exactly.No, don''t think so: ~ $ irb>> RUBY_VERSION=> "1.8.7">> "foo".start_with?("fo")=> true>> ^D~ $[ this is on Snow Leopard, mind, ] I''m not sure how much of Ruby you can use in ERB templates, but I''d have thought if a language feature works on irb, it''ll work in templates run on that machine. Templates are expanded on the puppetmaster, right? -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Fri, Mar 5, 2010 at 10:31 PM, Dick Davies <rasputnik@hellooperator.net> wrote:> On Thu, Mar 4, 2010 at 5:43 PM, Peter Meier <peter.meier@immerda.ch> wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >>>> Well, it workes in erb test, but not when puppet runs: >>>> >>>> undefined method `start_with?'' for.... via puppet >>>> >>>> erb -x -T ''-'' test.erb | ruby -c says Syntax OK.... >>> >>> I thought ''start_with" was a ruby 1.9 thing only? And "starts_with" is >>> a Rails-ism ? >> >> exactly. > > No, don''t think so: > > ~ $ irb >>> RUBY_VERSION > => "1.8.7" >>> "foo".start_with?("fo") > => true >>> ^D~ $Interesting. Looks like it appeared in 1.8.7 as well. $ irb>> RUBY_VERSION=> "1.8.6">> "foo".start_with?("fo")NoMethodError: undefined method `start_with?'' for "foo":String> > [ this is on Snow Leopard, mind, ] I''m not sure how much of Ruby you can > use in ERB templates, but I''d have thought if a language feature works > on irb, it''ll work in templates run on that machine. > > Templates are expanded on the puppetmaster, right?yes.> > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. > >-- nigel -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.