Hi,
Is there a way to export a list of all manually-defined nodes in a puppet
configuration?
I need to use this list in a script. Previously it was easy because I had each
node individually defined in nodes.pp ala
node ''blah1.com'' {
include stuff
}
node ''blah2.com'' {
include stuff
}
I could just grep the file for the word ''node'' and parse the
output. However, since many nodes have the same layout, I condensed the
configuration and now I don''t know how to extract the node names.
Current layout:
node ''blah1.com'', ''blah2.com'',
<snip>
''blah48.com, ''blah172.com'' {
include stuff
}
Is there a way to parse the node list with a puppet utility or a ruby script?
The output I''d like returned is very simple - 1 hostname per line.
P.S. Please don''t tell me to use LDAP :-)
--~--~---------~--~----~------------~-------~--~----~
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 1/6/2009 10:09 AM, John Philips wrote:> Is there a way to export a list of all manually-defined nodes in a > puppet configuration?At least on a Debian 0.24.6 puppetmaster, it appears that you can examine the .yaml files in $vardir/yaml/node -- I''d assume that works for any type of defined node, not just manually defined ones. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mike, I thought about that, but a directory listing includes all nodes that have connected to the puppetmaster (old or decommissioned servers, etc.). I''d like to get a list of nodes that are currently defined in the nodes.pp file. --- On Tue, 1/6/09, Mike Renfro <renfro@tntech.edu> wrote:> From: Mike Renfro <renfro@tntech.edu> > Subject: [Puppet Users] Re: Get list of all nodes > To: puppet-users@googlegroups.com > Date: Tuesday, January 6, 2009, 8:40 AM > On 1/6/2009 10:09 AM, John Philips wrote: > > > Is there a way to export a list of all > manually-defined nodes in a > > puppet configuration? > > At least on a Debian 0.24.6 puppetmaster, it appears that > you can > examine the .yaml files in $vardir/yaml/node -- I''d > assume that > works for any type of defined node, not just manually > defined ones. > > -- > Mike Renfro / R&D Engineer, Center for Manufacturing > Research, > 931 372-3601 / Tennessee Technological University > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Use LDAP.
I couldn''t resist. :-P
In all seriousness, though, grep is still your friend. He''s brought a
couple new friends to the table to help you with this problem; their
names are "sed" and "awk".
With the example below, this should give you what you want:
grep ^node site.pp | sed -e ''s/^node //'' | awk -F,
''{for(i=1;i<=NF;i++) {print $i}}''
HTH
--Paul
On Tue, Jan 6, 2009 at 8:09 AM, John Philips <johnphilips42@yahoo.com>
wrote:>
> Hi,
>
> Is there a way to export a list of all manually-defined nodes in a puppet
configuration?
>
> I need to use this list in a script. Previously it was easy because I had
each node individually defined in nodes.pp ala
>
> node ''blah1.com'' {
> include stuff
> }
> node ''blah2.com'' {
> include stuff
> }
>
> I could just grep the file for the word ''node'' and parse
the output. However, since many nodes have the same layout, I condensed the
configuration and now I don''t know how to extract the node names.
>
> Current layout:
>
> node ''blah1.com'', ''blah2.com'',
> <snip>
> ''blah48.com, ''blah172.com'' {
> include stuff
> }
>
> Is there a way to parse the node list with a puppet utility or a ruby
script? The output I''d like returned is very simple - 1 hostname per
line.
>
> P.S. Please don''t tell me to use LDAP :-)
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
> Use LDAP. > > I couldn''t resist. :-PHar har.> With the example below, this should give you what you want: > > grep ^node site.pp | sed -e ''s/^node //'' | awk -F, > ''{for(i=1;i<=NF;i++) {print $i}}''Thanks, that did the trick. Well, almost. The hostnames are in quotation marks so I piped it to yet another program for the final touch. grep ^node site.pp | sed -e ''s/^node //'' | awk -F, ''{for(i=1;i<=NF;i++) {print $i}}'' | cut -d "''" -f2 --~--~---------~--~----~------------~-------~--~----~ 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 Tue, Jan 6, 2009 at 9:50 AM, John Philips <johnphilips42@yahoo.com> wrote:> Thanks, that did the trick. Well, almost. The hostnames are in quotation marks so I piped it to yet another program for the final touch. > > grep ^node site.pp | sed -e ''s/^node //'' | awk -F, ''{for(i=1;i<=NF;i++) {print $i}}'' | cut -d "''" -f2Awesome. Do you need me to dissect it so you know *why* it works, or would you prefer to figure it out yourself? --Paul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---