Come to think of it, a dummy resource is better:

    define foo () { }

    node /app\d+\.example\.com$/ {
      foo { 'app\d.+\.example\.com$': }
    }

In that case you will be searching for the title of resource 'foo'.
The problem with my previous class solution was that it would only
work for 1 node search case due to lack of uniqueness. Sorry about
that :-).

On Fri, May 10, 2013 at 1:54 PM, Ken Barber <k...@puppetlabs.com> wrote:
> Let me get this straight ... so you want to be able to query PuppetDB
> for what 'node' match propagated that nodes configuration right?
>
> So in the case of 'app3.example.com' you want to be able to find it by
> looking for app\d+\.example\.com for example? Or you want to see all
> nodes that matches that search.
>
> Now, I don't think we store this by default in the catalog or anywhere
> else for that matter - the match is discarded after compilation. The
> only thing I can think of is if you use a particular class in those
> node definitions, or perhaps a dummy class to store that kind of
> information?
>
>     # My dummy class
>     class foo ($search) { }
>
>     node /app\d+\.example\.com$/ {
>       class { 'foo':
>         search => "app\d+\.example\.com$"
>       }
>     }
>
> This way the information gets stored in the catalog and is available
> for querying. Its obviously a bit unruly and extra manual work though.
> You could effectively use any class or resource to achieve this.
>
> Can I ask why you would want to do this? Perhaps there is an alternate 
> approach.
>
> ken.
>
> On Fri, May 10, 2013 at 8:31 AM, yorks <stuyo...@gmail.com> wrote:
>> puppet agent hostname: app1.example.com
>> site.pp:
>> node 'app2.example.com' { ...}
>> node /app\d+\.example\.com$/ { ... }
>> ...
>>
>> I can query the facter and resources from the puppetdb, but how can I get
>> which nodes(app2.example.com, app\d+.example.com...) it matching?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to puppet-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to puppet-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to