Hello, master chefs. I am new to Chef, I’m writing a recipe for mongoDB, and
have a general question about node-level attributes.
My mongoDB recipe works fine for standalone servers, and I would like to extend
it, to configure 2 different systems for replica pairing. The mongoDB config
file for each server should look exactly the same, except that one file will
have the directive “pairwith = ‘db1’”, while the other will have “pairwith =
It seems silly to create two different Chef roles for two nodes that differ
only by the value of one attribute. So my hope was that both servers can be
assigned the same “mongoDB” role (and by extension the same “mongodb” recipe),
but they would differ only by the value of the @node[:mongodb][:pairwith]
attribute, which would somehow be set at the node level.
However, I cannot figure out how to set attributes at the node level! I’ve
tried setting node-level attributes through the web GUI, but it doesn’t seem to
stick (on chef-server-0.7.10-0ubuntu1.1). Besides, I’d like to pre-define them,
so that I can keep them in my Chef repo, naturally.
What’s the preferred way to predefine a “node” – that is, a set of roles, and
the attributes that are to be applied only to that server? I’ve been able to do
it from the initial JSON that’s passed to the very first command-line
invocation of chef-client, when the client first registers itself with the
server. But after that, the value seems “locked-in”. How can I change
node-level attributes once a server is already running and registered?
Thanks in advance,