I have a nodes-operational.pp with various nodes defined. I would like to define a node using a regular expression like so: /^dev-[^\s]*(?<!geoserver)$/ That is, I would like to use the above expression to resolve nodes which are prefixed with ''dev'', but do not end with ''geoserver''. This results in the following error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment jf: undefined (?...) sequence: /^dev-[^\s]*(?<!geoserver)$/ at /etc/puppet/environments/jf/manifests/nodes-operational.pp:11 on node dev-jf... How can I achieve this? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/1Jk57vLqJqwJ. 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.
Bernd Adamowicz
2012-Aug-09 09:23 UTC
AW: [Puppet Users] Using regex in Puppet node definition
I''m not an expert in regular expression. But if I run into problems like this one, I always turn to this page: http://www.regexplanet.com/advanced/java/index.html Has always helped me. Bernd> -----Ursprüngliche Nachricht----- > Von: puppet-users@googlegroups.com [mailto:puppet- > users@googlegroups.com] Im Auftrag von James Fraser > Gesendet: Donnerstag, 9. August 2012 11:01 > An: puppet-users@googlegroups.com > Betreff: [Puppet Users] Using regex in Puppet node definition > > I have a nodes-operational.pp with various nodes defined. I would like > to define a node using a regular expression like so: > > /^dev-[^\s]*(?<!geoserver)$/ > > That is, I would like to use the above expression to resolve nodes > which are prefixed with ''dev'', but do not end with ''geoserver''. This > results in the following error: > > Could not retrieve catalog from remote server: Error 400 on SERVER: > Could not parse for environment jf: undefined (?...) sequence: /^dev- > [^\s]*(?<!geoserver)$/ at /etc/puppet/environments/jf/manifests/nodes- > operational.pp:11 on node dev-jf... > > How can I achieve this? > > -- > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/1Jk57vLqJqwJ. > 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 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 Aug 9, 2012, at 5:23 AM, Bernd Adamowicz wrote:> I''m not an expert in regular expression. But if I run into problems like this one, I always turn to this page: http://www.regexplanet.com/advanced/java/index.html Has always helped me. > > BerndVery nice tool page. Thanks for that link. -- 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.
Martin Willemsma
2012-Aug-09 12:07 UTC
Re: [Puppet Users] Using regex in Puppet node definition
Hi! In addition to Bernds link. That page is applicable to Java, there is also a page to test your Ruby regex: I like this one: http://rubular.com/ Martin 2012/8/9 Dan White <ygor@comcast.net>> > On Aug 9, 2012, at 5:23 AM, Bernd Adamowicz wrote: > > > I''m not an expert in regular expression. But if I run into problems like > this one, I always turn to this page: > http://www.regexplanet.com/advanced/java/index.html Has always helped me. > > > > Bernd > > Very nice tool page. Thanks for that link. > > -- > 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 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.
jcbollinger
2012-Aug-09 13:03 UTC
Re: [Puppet Users] Using regex in Puppet node definition
On Thursday, August 9, 2012 7:07:34 AM UTC-5, mawi wrote:> > Hi! > > In addition to Bernds link. That page is applicable to Java, there is also > a page to test your Ruby regex: > > I like this one: http://rubular.com/ >Yes, I think that''s more apropos in this context. To my knowledge, Puppet uses the underlying Ruby''s regex syntax. Rubular''s tester, which appears to do the same, would probably give more applicable answers. As to the OP''s question, however, I don''t think Ruby''s regex syntax recognizes zero-width assertions. This problem might be approachable via reliance on Puppet''s node matching behavior: if only regex node declarations and maybe a default declaration match a given node, then the lexically first matching regex node is used. Therefore, if all *geoserver nodes are matched by specific node declarations or earlier regex node declarations then the trailing assertion should not be needed. Example: node /.*geoserver$/ { # something } node /^dev-[^\s]*$/ { # something else } John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/iSVn2_tWx34J. 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.