Trevor Vaughan
2011-Nov-18 19:20 UTC
Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
Sorry if this is a double post, my e-mail glitched on me. Anyway, I''m trying to write a Ruby script that can get all defined nodes and all classes assigned to those nodes. I would prefer to not have to compile a catalog for each node. I tried looking through the puppet/util/rdoc material but it really didn''t handle the node entries as far as I could tell and also didn''t seem to have a way to get the info without printing it all out. Hopefully, I''m just missing something. Thanks, Trevor -- Trevor Vaughan Vice President, Onyx Point, Inc (410) 541-6699 tvaughan@onyxpoint.com -- This account not approved for unencrypted proprietary information -- -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Trevor Vaughan
2011-Nov-21 00:31 UTC
Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sorry but...bump? On 11/18/2011 02:20 PM, Trevor Vaughan wrote:> Sorry if this is a double post, my e-mail glitched on me. > > Anyway, I''m trying to write a Ruby script that can get all defined > nodes and all classes assigned to those nodes. I would prefer to not > have to compile a catalog for each node. > > I tried looking through the puppet/util/rdoc material but it really > didn''t handle the node entries as far as I could tell and also didn''t > seem to have a way to get the info without printing it all out. > > Hopefully, I''m just missing something. > > Thanks, > > Trevor >- -- Trevor Vaughan Vice President, Onyx Point, Inc. email: tvaughan@onyxpoint.com phone: 410-541-ONYX (6699) pgp: 0x6C701E94 - -- This account not approved for unencrypted sensitive information -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAEBAgAGBQJOyZvKAAoJECNCGV1OLcypjpIIAI+WmDinF/n8aDcMwDAi/QEw 5hmI/FKYXTsilkQMDC3SmATZD+GckQ3uBfMMFhEYRcFZ9lA/zGscdNJ+/oEbNteb pcUbQUN6ZzoqPMIHYXrYIwiFxu/09gpeIVC5vj6Z64YIE+fw0bndFpId5aTwLxO+ E3ya9UhIPtn2wCIwLYAwymC/++44kWT8Y5EwL76w0GnMR6tbVLrMGA9uTjhEQ0Nu ShdJlkdBfbpmFl8sfTKHaNuFKN99O3GzzOMvsuANuaRf9SwXfP5dzEZJ71CZbpUU LN4mEQdCKIaN/4VjFFhICXNpmYElHMPm3gEyUZfcgtwYM+u9fpsy/x/sDvTHeIU=61hm -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
James Turnbull
2011-Nov-21 02:04 UTC
Re: [Puppet Users] Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
Trevor Vaughan wrote:> Sorry but...bump? > > On 11/18/2011 02:20 PM, Trevor Vaughan wrote: >> Sorry if this is a double post, my e-mail glitched on me. > >> Anyway, I''m trying to write a Ruby script that can get all defined >> nodes and all classes assigned to those nodes. I would prefer to not >> have to compile a catalog for each node. > >> I tried looking through the puppet/util/rdoc material but it really >> didn''t handle the node entries as far as I could tell and also didn''t >> seem to have a way to get the info without printing it all out. >Sorry missed this one - I do something vaguely similar for the Puppet Rundeck integration - have a look at the code at: https://github.com/jamtur01/puppet-rundeck Others may be able to chime in with better ideas. James -- James Turnbull Puppet Labs 1-503-734-8571 To schedule a meeting with me: http://tungle.me/jamtur01 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Trevor Vaughan
2011-Nov-21 02:24 UTC
Re: Re: [Puppet Users] Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks James. I knew how to do that, I was actually trying to figure out if I could do it the hard way by delving the manifests instead of having to wait for a system to check in. I''m pretty close to saying that the answer is ''no''. Thanks, Trevor On 11/20/2011 09:04 PM, James Turnbull wrote:> Trevor Vaughan wrote: >> Sorry but...bump? >> >> On 11/18/2011 02:20 PM, Trevor Vaughan wrote: >>> Sorry if this is a double post, my e-mail glitched on me. >> >>> Anyway, I''m trying to write a Ruby script that can get all defined >>> nodes and all classes assigned to those nodes. I would prefer to not >>> have to compile a catalog for each node. >> >>> I tried looking through the puppet/util/rdoc material but it really >>> didn''t handle the node entries as far as I could tell and also didn''t >>> seem to have a way to get the info without printing it all out. >> > > Sorry missed this one - I do something vaguely similar for the Puppet > Rundeck integration - have a look at the code at: > > https://github.com/jamtur01/puppet-rundeck > > Others may be able to chime in with better ideas. > > James >- -- Trevor Vaughan Vice President, Onyx Point, Inc. email: tvaughan@onyxpoint.com phone: 410-541-ONYX (6699) pgp: 0x6C701E94 - -- This account not approved for unencrypted sensitive information -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAEBAgAGBQJOybZGAAoJECNCGV1OLcypYvIH/3DoC9SbHzctKzCYPGCBVjrH A9l7xN09I/zqu7tQpdi25V1yZNH9UgiSLRGGe2clzrP9Ep+4t/8FCD9o2quwOAES mTO0cmJGVgkS6TZRTIRZjkle2r2mRtBO/oB5kuxYFe4dWx8RompxbvVjsPUs/BY8 jG/TcZ7f1KhjnNjwMmRkJQZb4KhENjqS6jxr8xPiS1OKapswr+UuJAz8xqefJww4 hX7UkpJ1FQKDIpc+Utq01cmYRr1Fp5syLRmCSmQ3k0XIIQopMQ4PrjOAO8sfamdQ 77la9dYg0DFEw2AxgOtG6C/NpHmDOAsdizppdM7Og4U5iDUf00HR+2FmH+gi3ds=TNkm -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
James Turnbull
2011-Nov-21 02:35 UTC
Re: Re: [Puppet Users] Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
Trevor Vaughan wrote:> Thanks James. > > I knew how to do that, I was actually trying to figure out if I could do it the hard way by delving the manifests instead of having to wait for a > system to check in. > > I''m pretty close to saying that the answer is ''no''. >Oh I see. You mean before the catalog is compiled? I think the only way to do that IS compile the catalog. But again others may be smarter than me. :) James -- James Turnbull Puppet Labs 1-503-734-8571 To schedule a meeting with me: http://tungle.me/jamtur01 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Brian Gallew
2011-Nov-21 17:10 UTC
Re: [Puppet Users] Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
This is (almost) trivial. First, create a fact that turns /var/lib/puppet/state/classes.txt into an array. Then extract that fact from the storedconfigs DB programmatically. Admittedly, this won''t get all defined nodes, as that is somewhat meaningless since nodes can be "default" or regular exceptions. Instead, this gets all nodes that have run Puppet at least once. On Nov 20, 2011, at 6:04 PM, James Turnbull wrote:> Trevor Vaughan wrote: >> Sorry but...bump? >> >> On 11/18/2011 02:20 PM, Trevor Vaughan wrote: >>> Sorry if this is a double post, my e-mail glitched on me. >> >>> Anyway, I''m trying to write a Ruby script that can get all defined >>> nodes and all classes assigned to those nodes. I would prefer to not >>> have to compile a catalog for each node. >> >>> I tried looking through the puppet/util/rdoc material but it really >>> didn''t handle the node entries as far as I could tell and also didn''t >>> seem to have a way to get the info without printing it all out. >> > > Sorry missed this one - I do something vaguely similar for the Puppet > Rundeck integration - have a look at the code at: > > https://github.com/jamtur01/puppet-rundeck > > Others may be able to chime in with better ideas. > > James > > -- > James Turnbull > Puppet Labs > 1-503-734-8571 > To schedule a meeting with me: http://tungle.me/jamtur01 > > -- > 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. >-- 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.
Trevor Vaughan
2011-Nov-22 00:43 UTC
Re: [Puppet Users] Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks for the suggestions guys but I''m giving this one up as too annoying to bother. The issue was to detect the nodes that hadn''t checked in but were defined in the manifest. Getting the information out of the YAML is pretty easy, yes. Thanks! Trevor On 11/21/2011 12:10 PM, Brian Gallew wrote:> This is (almost) trivial. > First, create a fact that turns /var/lib/puppet/state/classes.txt into an array. Then extract that fact from the storedconfigs DB programmatically. Admittedly, this won''t get all defined nodes, as that is somewhat meaningless since nodes can be "default" or regular exceptions. Instead, this gets all nodes that have run Puppet at least once. > > On Nov 20, 2011, at 6:04 PM, James Turnbull wrote: > >> Trevor Vaughan wrote: >>> Sorry but...bump? >>> >>> On 11/18/2011 02:20 PM, Trevor Vaughan wrote: >>>> Sorry if this is a double post, my e-mail glitched on me. >>> >>>> Anyway, I''m trying to write a Ruby script that can get all defined >>>> nodes and all classes assigned to those nodes. I would prefer to not >>>> have to compile a catalog for each node. >>> >>>> I tried looking through the puppet/util/rdoc material but it really >>>> didn''t handle the node entries as far as I could tell and also didn''t >>>> seem to have a way to get the info without printing it all out. >>> >> >> Sorry missed this one - I do something vaguely similar for the Puppet >> Rundeck integration - have a look at the code at: >> >> https://github.com/jamtur01/puppet-rundeck >> >> Others may be able to chime in with better ideas. >> >> James >> >> -- >> James Turnbull >> Puppet Labs >> 1-503-734-8571 >> To schedule a meeting with me: http://tungle.me/jamtur01 >> >> -- >> 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. >> >- -- Trevor Vaughan Vice President, Onyx Point, Inc. email: tvaughan@onyxpoint.com phone: 410-541-ONYX (6699) pgp: 0x6C701E94 - -- This account not approved for unencrypted sensitive information -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAEBAgAGBQJOyvARAAoJECNCGV1OLcypxvYH/03J2v+V+ReyewLkA5wynTq+ J9NbiXjwqKK7RZOlB+LFrIbR8/OBP46zRLSI0iujfwua3vwQromA9wga59e9XvuL vFsKiKmwxArzcrafuTNnIk47jyV6vvYvxq7roIqcU0kQIj9rECEJSkktNI/gy8PK DMiIMqNSz6jGw+ZUAhWJMQtvzLZ73BiFl61WKFH0NEAM1uBIidp4hfPQ9Bn2OVPJ TLfGlN2/nuFVUFU6SgDICFsaXKuM6Cc4CnUH1o+UJH6SKXXZBtnuXZDncmwsA4ez BG+fP3rfS4q3EzZYrl05zFh4frsLyo5PQDYKTZyALPDY9QmZvkHQ62IloFLYcdY=8sEZ -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Gonzalo Servat
2011-Nov-22 02:03 UTC
Re: [Puppet Users] Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
I rely on Puppet dashboard to tell me which nodes haven''t checked in for a while... :) - Gonzalo On Tue, Nov 22, 2011 at 11:43 AM, Trevor Vaughan <tvaughan@onyxpoint.com>wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Thanks for the suggestions guys but I''m giving this one up as too annoying > to bother. > > The issue was to detect the nodes that hadn''t checked in but were defined > in the manifest. > > Getting the information out of the YAML is pretty easy, yes. > > Thanks! > > Trevor > > On 11/21/2011 12:10 PM, Brian Gallew wrote: > > This is (almost) trivial. > > First, create a fact that turns /var/lib/puppet/state/classes.txt into > an array. Then extract that fact from the storedconfigs DB > programmatically. Admittedly, this won''t get all defined nodes, as that is > somewhat meaningless since nodes can be "default" or regular exceptions. > Instead, this gets all nodes that have run Puppet at least once. > > > > On Nov 20, 2011, at 6:04 PM, James Turnbull wrote: > > > >> Trevor Vaughan wrote: > >>> Sorry but...bump? > >>> > >>> On 11/18/2011 02:20 PM, Trevor Vaughan wrote: > >>>> Sorry if this is a double post, my e-mail glitched on me. > >>> > >>>> Anyway, I''m trying to write a Ruby script that can get all defined > >>>> nodes and all classes assigned to those nodes. I would prefer to not > >>>> have to compile a catalog for each node. > >>> > >>>> I tried looking through the puppet/util/rdoc material but it really > >>>> didn''t handle the node entries as far as I could tell and also didn''t > >>>> seem to have a way to get the info without printing it all out. > >>> > >> > >> Sorry missed this one - I do something vaguely similar for the Puppet > >> Rundeck integration - have a look at the code at: > >> > >> https://github.com/jamtur01/puppet-rundeck > >> > >> Others may be able to chime in with better ideas. > >> > >> James > >> > >> -- > >> James Turnbull > >> Puppet Labs > >> 1-503-734-8571 > >> To schedule a meeting with me: http://tungle.me/jamtur01 > >> > >> -- > >> 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. > >> > > > > - -- > Trevor Vaughan > Vice President, Onyx Point, Inc. > email: tvaughan@onyxpoint.com > phone: 410-541-ONYX (6699) > pgp: 0x6C701E94 > > - -- This account not approved for unencrypted sensitive information -- > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.11 (GNU/Linux) > > iQEcBAEBAgAGBQJOyvARAAoJECNCGV1OLcypxvYH/03J2v+V+ReyewLkA5wynTq+ > J9NbiXjwqKK7RZOlB+LFrIbR8/OBP46zRLSI0iujfwua3vwQromA9wga59e9XvuL > vFsKiKmwxArzcrafuTNnIk47jyV6vvYvxq7roIqcU0kQIj9rECEJSkktNI/gy8PK > DMiIMqNSz6jGw+ZUAhWJMQtvzLZ73BiFl61WKFH0NEAM1uBIidp4hfPQ9Bn2OVPJ > TLfGlN2/nuFVUFU6SgDICFsaXKuM6Cc4CnUH1o+UJH6SKXXZBtnuXZDncmwsA4ez > BG+fP3rfS4q3EzZYrl05zFh4frsLyo5PQDYKTZyALPDY9QmZvkHQ62IloFLYcdY> =8sEZ > -----END PGP SIGNATURE----- > > -- > 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. > >-- 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.
david-dasz
2011-Nov-22 09:46 UTC
Re: Re: [Puppet Users] Re: Is it possible to get a list of all nodes in your manifests and all classes assigned to those nodes programatically in Ruby?
Hi Trevor, In the case of a default node, regexp nodes or an external node classifier, there *is* no well-defined "list of potential nodes" any more. Having said that, a solution might be to use the puppet compiler''s internals to parse the site.pp and friends "manually" and access the AST resulting from this parse. I''ve no idea if and how that could work technically though. Best Regards, David On Mon, 21 Nov 2011 19:43:06 -0500, Trevor Vaughan <tvaughan@onyxpoint.com> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Thanks for the suggestions guys but I''m giving this one up as tooannoying> to bother. > > The issue was to detect the nodes that hadn''t checked in but weredefined> in the manifest. > > Getting the information out of the YAML is pretty easy, yes. > > Thanks! > > Trevor > > On 11/21/2011 12:10 PM, Brian Gallew wrote: >> This is (almost) trivial. >> First, create a fact that turns /var/lib/puppet/state/classes.txt into >> an array. Then extract that fact from the storedconfigs DB >> programmatically. Admittedly, this won''t get all defined nodes, asthat>> is somewhat meaningless since nodes can be "default" or regular >> exceptions. Instead, this gets all nodes that have run Puppet at least >> once. >> >> On Nov 20, 2011, at 6:04 PM, James Turnbull wrote: >> >>> Trevor Vaughan wrote: >>>> Sorry but...bump? >>>> >>>> On 11/18/2011 02:20 PM, Trevor Vaughan wrote: >>>>> Sorry if this is a double post, my e-mail glitched on me. >>>> >>>>> Anyway, I''m trying to write a Ruby script that can get all defined >>>>> nodes and all classes assigned to those nodes. I would prefer to not >>>>> have to compile a catalog for each node. >>>> >>>>> I tried looking through the puppet/util/rdoc material but it really >>>>> didn''t handle the node entries as far as I could tell and alsodidn''t>>>>> seem to have a way to get the info without printing it all out. >>>> >>> >>> Sorry missed this one - I do something vaguely similar for the Puppet >>> Rundeck integration - have a look at the code at: >>> >>> https://github.com/jamtur01/puppet-rundeck >>> >>> Others may be able to chime in with better ideas. >>> >>> James >>> >>> -- >>> James Turnbull >>> Puppet Labs >>> 1-503-734-8571 >>> To schedule a meeting with me: http://tungle.me/jamtur01 >>> >>> -- >>> 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. >>> >> > > - -- > Trevor Vaughan > Vice President, Onyx Point, Inc. > email: tvaughan@onyxpoint.com > phone: 410-541-ONYX (6699) > pgp: 0x6C701E94 > > - -- This account not approved for unencrypted sensitive information -- > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.11 (GNU/Linux) > > iQEcBAEBAgAGBQJOyvARAAoJECNCGV1OLcypxvYH/03J2v+V+ReyewLkA5wynTq+ > J9NbiXjwqKK7RZOlB+LFrIbR8/OBP46zRLSI0iujfwua3vwQromA9wga59e9XvuL > vFsKiKmwxArzcrafuTNnIk47jyV6vvYvxq7roIqcU0kQIj9rECEJSkktNI/gy8PK > DMiIMqNSz6jGw+ZUAhWJMQtvzLZ73BiFl61WKFH0NEAM1uBIidp4hfPQ9Bn2OVPJ > TLfGlN2/nuFVUFU6SgDICFsaXKuM6Cc4CnUH1o+UJH6SKXXZBtnuXZDncmwsA4ez > BG+fP3rfS4q3EzZYrl05zFh4frsLyo5PQDYKTZyALPDY9QmZvkHQ62IloFLYcdY> =8sEZ > -----END PGP SIGNATURE------- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.