On Sep 18, 2009, at 10:31 AM, 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.
>
> 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.
>
> With the new code, I don't get parse failures but in no case do I get
> two notices emitted.
>
>
> [[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
> ### 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
> ### 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
> ### 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

As Brice said, the concept of a node at this point is that you only  
ever match one of them.  You should be able to get this behaviour with  
case or if statements:

if $hostname =~ /foo/ { ... }

but I realize that's an uglier syntax.

I'm not entirely opposed to this idea of multiple node blocks  
matching, but it wouldn't happen for 0.25.1, and really, I think it  
probably makes more sense in an external node tool, as Brice suggests.

-- 
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to