On Thu, Oct 10, 2013 at 6:12 AM, Pablo Fernandez <pablo.fernan...@cscs.ch>wrote:
> Thanks Ken, > > I took a look at the Command API and seems to be quite interesting, but > it triggers a few more questions. > > As a reminder (also for others), what I wanted to do was to add exported > resources from Node_A (managed by PuppetMaster_A that has its own > PuppetDB_A) into a different PuppetDB_B, where Node_A is unknown, in > order for other Nodes_B (managed by PuppetMaster_B) be aware and > possibly realize those exported resources. > > Taking a look the Commands API seem to capabilities to change a whole > catalog, or facts. Do they need to be existing catalogs, or could I add > new ones? > I am thinking: If I want to add Node_A's exported resource(s) to > PuppetDB_B, I could "artificially" add its whole catalog to > PuppetDB_B... but the Command API is "replace catalog", no "add > catalog". Would it be rejected? How does the first catalog of a node get > introduced into the DB? And moreover, how do I query a whole catalog? > Lots of great questions here! :) * You can certainly add the whole catalog for a node to a secondary PuppetDB * The command is called "replace catalog" to indicate that it's, well, a replacement operation. So if you already have a catalog for node foo.comstored, issuing a "replace catalog" with a new catalog for foo.com will cause PuppetDB to delete the old catalog and store the new one for foo.com. It does this atomically, of course. This is "normal" operation for PuppetDB, as it only stores a single catalog for a given node. * A "replace catalog" command won't be rejected if there's already a catalog for that node; it'll just tell PuppetDB to store new data in place of the old data. In fact, this is how PuppetDB works with puppetmasters today...an agent requests a catalog from the master, the master compiles it for the agent, and the master issues a "replace catalog" command to puppetdb accordingly. * There is an endpoint to get the catalog for a node: /v3/catalogs/foo.com. The wire format of the result should be the same, documented catalog wire format as during insertion: http://docs.puppetlabs.com/puppetdb/1.5/api/wire_format/catalog_format.html. I do believe, though, that we overlooked adding documentation for this new endpoint...apologies! A pull req adding those docs to the documentation/ directory of puppetdb would be much appreciated. :) > > Another possibility would be to include the resource inside an existing > Node_B catalog on the PuppetDB_B (after all, exported resources don't > really mater what node do they belong, as long as they have the right > attributes, right?), but the Catalog wire format seems to require the > whole set of resources, so, if I define the resources of Node_B with > some exported resources from Node_A, I believe I would lose the original > Node_B's resources. The only possibility would be to query Node_B full > catalog, and *add also* those resources from Node_A before sending them > to the DB... and this seems to me like a bit dirty :) > Yes, you'd have to get the catalog for a node, modify it, and resubmit it. Remember that command submission is asynchronous, commands can be retried, etc. If you have a command of the form "add some resources to the currently stored catalog", the definition of "currently stored" isn't a static thing. It's thus subject to race conditions and other confusion. By requiring an entire catalog be submitted, and by making it clear through the name of the command itself ("replace catalog") a large class of problems go away while still keeping throughput high and retry-handling manageable. I'm not opposed to the idea of a "merge" type of command for catalogs, of course...but I think it's something that should be approached cautiously, with a good understanding of how it will impact (and be impacted by) the rest of the system. Maybe doing something like a command that merged a set of resources into a known, specific catalog (identified by a stable hash or id) would work? > > Am I missing anything? Or is there another way to implemen what I need > with Puppet 3.2? > > Thanks again, > BR/Pablo > > > On 10/10/2013 09:16 AM, Ken Barber wrote: > >>> Is there a mechanism to pull and push some exported resources from one > >>> PuppetDB to another? I guess this could be done with the API, but has > >>> anybody tried it, or will it work at all? > > Not provided by us, yet. We've had a lot of discussions internally > > about this kind of thing. How about you outline your requirements in > > the form of a feature request here: > > > > http://projects.puppetlabs.com/projects/puppetdb/issues > > > >> Did anybody try to push data to a PuppetDB by hand? The API does not > >> seem to have the PUT or POST methods. > > The client obviously pushes uses POST :-). The documentation for the > > mechanism is here: > > > > http://docs.puppetlabs.com/puppetdb/1.5/api/commands.html > > > > ken. > > > > -- > 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. > 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. For more options, visit https://groups.google.com/groups/opt_out.