Hi Eric, On 18/09/09 19:31, Eric Sorenson wrote: > On Sep 16, 2009, at 11:19 AM, Brice Figureau wrote: > >> When we are checking if a node exists before creating a new one >> we were also trying to match with regex node names, finding matches >> where in fact there is no equality. > > Hi Brice, thanks for the patch. I pulled the latest from master for > testing. This does indeed fix the parse failure I filed the bug about, > but I'm not sure if it achieves the goal I was shooting for. Can you > help me understand if I am asking for something stupid? (I have to > qualify all of this with self-doubt because I'm coming off a ten-year- > long cfengine habit and my thinking may be warped beyond help!) > > At a high level I was hoping to use regexp matching to make puppet > nodes.pp akin to cfengine's 'classes' section, where you'd set up user- > defined names for later use by matching hostnames, IPs or whatnot. So > my thought was I'd match different parts of the hostnames to include > the right puppet classes, kind of like pulling the external node > classifier functionality into static files.
My first reading of your e-mail proved to be wrong. I was hinted below at what you want to achieve. Basically in Puppet an hostname maps to only one node definition. The regex stuff didn't change this paradigm (and frankly I'm used to this so I didn't even though about this possibility). > If that goal is legitimate, my next question is whether these tests > are legit. I made four test cases to cover permutations of the two > things that seemed to matter: two regexp vs regexp+quoted nodename, > and quoting-first vs quoting-second. I expect the notices should fire > as each stanza is entered, which is a simplification to the real goal > of 'include'-ing various classes in each node stanza, to compose the > right list for a given node. The rule is: * if there is a non-regex node that match the current hostname or fqdn, then, then use it * if none match, scan the node regex in the order they were parsed, and stop at the first match. > With the new code, I don't get parse failures but in no case do I get > two notices emitted. Ah, that was the hint that I missed in my first reading. As explained above, this is how puppet is designed. > [[email protected] ~/Sandbox/dotmac/puppet/etc/sandbox]% for f > in node???-?regexp.pp ; do echo "### $f " ; cat $f; puppet $f ; done > ### node1st-1regexp.pp > node "recury.explosive.net" { > notice "we are recury" > } > > node /^(a|b|c|d|j|r)/ { > notice "we start with a,b,c,d,j,r" > } > > notice: Scope(Node[recury.explosive.net]): we are recury This one is OK. > ### node1st-2regexp.pp > node /recury/ { > notice "we are recury" > } > > node /^(a|b|c|d|j|r)/ { > notice "we start with a,b,c,d,j,r" > } > > notice: Scope(Node[recury.explosive.net]): we are recury OK, too. > ### node2nd-1regexp.pp > node /^(a|b|c|d|j|r)/ { > notice "we start with a,b,c,d,j,r" > } > > node "recury.explosive.net" { > notice "we are recury" > } > notice: Scope(Node[recury.explosive.net]): we are recury OK, even though the regex can match, we have a direct match with the node using the fqdn. > ### node2nd-2regexp.pp > node /^(a|b|c|d|j|r)/ { > notice "we start with a,b,c,d,j,r" > } > > node /recury/ { > notice "we are recury" > } > notice: Scope(Node[recury.explosive.net]): we start with a,b,c,d,j,r This one is conform too. I think you need a external node classifier to do what you want. -- Brice Figureau My Blog: http://www.masterzen.fr/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
