On Jan 21, 2011, at 6:49 PM, Micah Wedemeyer wrote:
Is anyone doing Mongo sharding or replica sets with chef?
You may be interested in some code from a mongoDB recipe we have used at Aranetic. Within our mongoDB cookbook, the regular default.rb recipe file takes care of the usual business of installing the software and writing the replica set name into the config file. That’s the easy part.
Otherwise, I need to wait for the server to come up, send it the command, and then hope that everything works.
Exactly. As you say, the tricky part is waiting for the server to come up (which can take a LONG time, depending on the size of the data you’re replicating, and your disk speed), and then sending the proper commands needed to establish replication. One wrinkle is that establishing the server as a slave involves contacting the master, and altering its configuration directly. To determine which nodes might be the master, this recipe searches the Chef server for all existing nodes with the same attribute vale [:mongodb][:repl_set].
The following code attempts to do all of that, in the context of a Chef recipe:
One thing this recipe does NOT do is to remove no-longer-reachable nodes from the master’s replication config. Another is sharding. Further collaboration on both aspects is welcome.
PGP Key ID 0x133E098F