Anyone know of any issues in 2.7.9 when trying to use a regex pattern for matching a hostname? If I specify the following below the client never loads the proper class, but if I put the fully qualified name in it works fine. Fails: node /somehost.*/ { include some::class } Works: node /somehost.domain.com/ { include some::class } -- 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.
Christopher Johnston
2012-Feb-23 14:33 UTC
[Puppet Users] Re: node regex not working in 2.7.9
Anyone have any ideas here? All these manifests worked fine in 2.5 puppet and suddenly broke in 2.7.9 when we upgraded. On Feb 22, 2012, at 8:42 PM, Christopher Johnston <chjohnst@gmail.com> wrote:> Anyone know of any issues in 2.7.9 when trying to use a regex pattern for matching a hostname? If I specify the following below the client never loads the proper class, but if I put the fully qualified name in it works fine. > > Fails: > > node /somehost.*/ { > include some::class > } > > Works: > > node /somehost.domain.com/ { > include some::class > }-- 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 Feb 22, 7:42 pm, Christopher Johnston <chjoh...@gmail.com> wrote:> Anyone know of any issues in 2.7.9 when trying to use a regex pattern for > matching a hostname? If I specify the following below the client never > loads the proper class, but if I put the fully qualified name in it works > fine. > > Fails: > > node /somehost.*/ { > include some::class > } > > Works: > > node /somehost.domain.com/ { > include some::class > }That''s very surprising, especially since you are using regex in both cases, and any string matched by the longer should also be matched by the shorter. Are you sure it''s the shorter one that fails? If it were the longer, then that would make some sense because hostnames are often taken as the *unqualified* names. I''m not aware of any issues with node regexes, and I don''t see any open issues on that subject in the bug tracker. It should be possible to strip this down to a very simple test case. For example, make this your whole site.pp: ===node /somehost.*/ { notify { ''node declaration'': message => "short regex matches ''$ {hostname}''" } } node /somehost.somedomain.com/ { notify { ''node declaration'': message => "long regex matches ''$ {hostname}''" } } node default { notify { ''node declaration'': message => "no regex matches ''$ {hostname}''" } } === If the first regex matches then that node declaration will be used; otherwise, if the second matches then that declaration will be used. If neither regex matches then the default node declaration will be used. Putting all those in one place allows you to be certain that the same hostname is being tested against each regex, and whichever node declaration is used, the hostname that was tested will be displayed in the client log. If that doesn''t give you enough to work out the problem then please post the actual test manifest and the resulting client log. Some other things to consider: 1) if you plan to match against actual hostnames then regex is way overkill. Just use the appropriate hostnames themselves (preferrably quoted). 2) the period is a regex metacharacter, so the difference between / somehost.*/ and /somehost\..*/ may be important to you 3) node regexes are not automatically anchored to the beginning or end of the hostname. If you want that (and it looks like you probably do) then you must put in the anchors yourself (e.g. /^somehost\..*$/). John -- 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.
Christopher Johnston
2012-Feb-23 18:37 UTC
Re: [Puppet Users] Re: node regex not working in 2.7.9
John, Thx for your reply, yea putting notifies in would be useful but simply seeing the class not get run or not included in classes.txt is also an indicator that its not working. I actually have a few regex for standard hostnames in our company here, simple stuff that is service oriented dev*, etc node /^dev[1-2]\..*\.(com|int)$/ { include server::dev } That is one node type that is NOT working, the regex is plain/simple and looks like it should work to me. We make a backup of our classes.txt daily and I looked at the day from right before the upgrade and it was working correctly. Since the upgrade it fails. I also just for testing purposes I loaded up the FQDN of the host in the regex match and it works fine. But anything where we are looking for complex (well not really) matching it fails. Putting a node type for every single host is way overkill, regexes should just work and are very convenient for our environment as we are very particular about hostname standards since our servers are generally service oriented and require a specific class for that service. -Chris On Thu, Feb 23, 2012 at 9:34 AM, jcbollinger <John.Bollinger@stjude.org>wrote:> > > On Feb 22, 7:42 pm, Christopher Johnston <chjoh...@gmail.com> wrote: > > Anyone know of any issues in 2.7.9 when trying to use a regex pattern for > > matching a hostname? If I specify the following below the client never > > loads the proper class, but if I put the fully qualified name in it works > > fine. > > > > Fails: > > > > node /somehost.*/ { > > include some::class > > } > > > > Works: > > > > node /somehost.domain.com/ { > > include some::class > > } > > > That''s very surprising, especially since you are using regex in both > cases, and any string matched by the longer should also be matched by > the shorter. Are you sure it''s the shorter one that fails? If it > were the longer, then that would make some sense because hostnames are > often taken as the *unqualified* names. > > I''m not aware of any issues with node regexes, and I don''t see any > open issues on that subject in the bug tracker. > > It should be possible to strip this down to a very simple test case. > For example, make this your whole site.pp: > ===> node /somehost.*/ { > notify { ''node declaration'': message => "short regex matches ''$ > {hostname}''" } > } > > node /somehost.somedomain.com/ { > notify { ''node declaration'': message => "long regex matches ''$ > {hostname}''" } > } > > node default { > notify { ''node declaration'': message => "no regex matches ''$ > {hostname}''" } > } > ===> > If the first regex matches then that node declaration will be used; > otherwise, if the second matches then that declaration will be used. > If neither regex matches then the default node declaration will be > used. Putting all those in one place allows you to be certain that > the same hostname is being tested against each regex, and whichever > node declaration is used, the hostname that was tested will be > displayed in the client log. If that doesn''t give you enough to work > out the problem then please post the actual test manifest and the > resulting client log. > > Some other things to consider: > 1) if you plan to match against actual hostnames then regex is way > overkill. Just use the appropriate hostnames themselves (preferrably > quoted). > 2) the period is a regex metacharacter, so the difference between / > somehost.*/ and /somehost\..*/ may be important to you > 3) node regexes are not automatically anchored to the beginning or end > of the hostname. If you want that (and it looks like you probably do) > then you must put in the anchors yourself (e.g. /^somehost\..*$/). > > > John > > -- > 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.
Christopher Johnston
2012-Feb-23 21:39 UTC
Re: [Puppet Users] Re: node regex not working in 2.7.9
I think I found my issue, we may have had doubling of node types. One file has node /someregex/, and another has node theactualhost, so could be that we are duplicating node definition/namespaces. -Chris On Thu, Feb 23, 2012 at 1:37 PM, Christopher Johnston <chjohnst@gmail.com>wrote:> John, > > Thx for your reply, yea putting notifies in would be useful but simply > seeing the class not get run or not included in classes.txt is also an > indicator that its not working. > > I actually have a few regex for standard hostnames in our company here, > simple stuff that is service oriented dev*, etc > > node /^dev[1-2]\..*\.(com|int)$/ { > include server::dev > } > > That is one node type that is NOT working, the regex is plain/simple and > looks like it should work to me. We make a backup of our classes.txt daily > and I looked at the day from right before the upgrade and it was working > correctly. Since the upgrade it fails. > > I also just for testing purposes I loaded up the FQDN of the host in the > regex match and it works fine. But anything where we are looking for > complex (well not really) matching it fails. > > Putting a node type for every single host is way overkill, regexes should > just work and are very convenient for our environment as we are very > particular about hostname standards since our servers are generally service > oriented and require a specific class for that service. > > -Chris > > > On Thu, Feb 23, 2012 at 9:34 AM, jcbollinger <John.Bollinger@stjude.org>wrote: > >> >> >> On Feb 22, 7:42 pm, Christopher Johnston <chjoh...@gmail.com> wrote: >> > Anyone know of any issues in 2.7.9 when trying to use a regex pattern >> for >> > matching a hostname? If I specify the following below the client never >> > loads the proper class, but if I put the fully qualified name in it >> works >> > fine. >> > >> > Fails: >> > >> > node /somehost.*/ { >> > include some::class >> > } >> > >> > Works: >> > >> > node /somehost.domain.com/ { >> > include some::class >> > } >> >> >> That''s very surprising, especially since you are using regex in both >> cases, and any string matched by the longer should also be matched by >> the shorter. Are you sure it''s the shorter one that fails? If it >> were the longer, then that would make some sense because hostnames are >> often taken as the *unqualified* names. >> >> I''m not aware of any issues with node regexes, and I don''t see any >> open issues on that subject in the bug tracker. >> >> It should be possible to strip this down to a very simple test case. >> For example, make this your whole site.pp: >> ===>> node /somehost.*/ { >> notify { ''node declaration'': message => "short regex matches ''$ >> {hostname}''" } >> } >> >> node /somehost.somedomain.com/ { >> notify { ''node declaration'': message => "long regex matches ''$ >> {hostname}''" } >> } >> >> node default { >> notify { ''node declaration'': message => "no regex matches ''$ >> {hostname}''" } >> } >> ===>> >> If the first regex matches then that node declaration will be used; >> otherwise, if the second matches then that declaration will be used. >> If neither regex matches then the default node declaration will be >> used. Putting all those in one place allows you to be certain that >> the same hostname is being tested against each regex, and whichever >> node declaration is used, the hostname that was tested will be >> displayed in the client log. If that doesn''t give you enough to work >> out the problem then please post the actual test manifest and the >> resulting client log. >> >> Some other things to consider: >> 1) if you plan to match against actual hostnames then regex is way >> overkill. Just use the appropriate hostnames themselves (preferrably >> quoted). >> 2) the period is a regex metacharacter, so the difference between / >> somehost.*/ and /somehost\..*/ may be important to you >> 3) node regexes are not automatically anchored to the beginning or end >> of the hostname. If you want that (and it looks like you probably do) >> then you must put in the anchors yourself (e.g. /^somehost\..*$/). >> >> >> John >> >> -- >> 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.