yorks
2013-May-10 07:31 UTC
[Puppet Users] is there a way to find an agent in which node by puppetdb api
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+unsubscribe@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.
Ken Barber
2013-May-10 12:54 UTC
Re: [Puppet Users] is there a way to find an agent in which node by puppetdb api
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 <stuyorks@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+unsubscribe@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+unsubscribe@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.
Ken Barber
2013-May-10 12:57 UTC
Re: [Puppet Users] is there a way to find an agent in which node by puppetdb api
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 <ken@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 <stuyorks@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+unsubscribe@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+unsubscribe@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.
yorks
2013-May-13 03:06 UTC
Re: [Puppet Users] is there a way to find an agent in which node by puppetdb api
yes, I want to find ''app3.example.com'' in which define node.
pool for my english. I will show you the bash:
[yorks@app3 ~]$ fgrep -A 2 \[agent\] /etc/puppet/puppet.conf
[agent]
classfile = $vardir/classes.txt
[yorks@app3 puppet]$ head -n 2 classes.txt
settings
appd.example.com
I want to find the value ''appd.example.com'' through puppetdb.
something like this:
curl -H "Accept: application/json"
http://puppetdb:8080/nodes/app3.example.com/manifest
[{''file'':site.pp,
''node'':''app\d+\.example\.com$'',''line'':1}...]
your ''dummy class'' is a good solution, but every node in
site.pp i want to
add foo ...
thank you!
在 2013年5月10日星期五UTC+8下午8时54分17秒,Ken Barber写道:>
> 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 <stuy...@gmail.com
<javascript:>>
> 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...@googlegroups.com <javascript:>.
> > To post to this group, send email to
puppet...@googlegroups.com<javascript:>.
>
> > 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+unsubscribe@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.