[chef] Re: Identifying if a node is being bootstrapped


Chronological Thread 
  • From: Rob Guttman < >
  • To:
  • Cc:
  • Subject: [chef] Re: Identifying if a node is being bootstrapped
  • Date: Fri, 9 Mar 2012 09:29:32 -0500

John, I probably don't understand your needs in full, but this is what I do:

 1. knife bootstrap with a special bootstrap role
 2. immediately when done, set the node's TRUE role(s)

In other words, use knife bootstrap for bootstrapping!  I happen to use Trac's Cloud plugin for this orchestration (I'm the author) which is just a simple wrapper of pychef and boto, but I'm there are many other easy ways of changing a node's role and attributes.

- Rob


On Mar 9, 2012, at 1:04 AM, John E. Vincent (lusis) wrote:

Hey all,

Came across a situation tonight that I wanted to get feedback on. I've
got some standard patterns I use for dealing with TRUE one-time run
recipes.

A concrete example was from my previous employer was something like this:

- spin up node of role "fooapp" with additional recipe "fooapp::bootstrap"
- at the end of the run, the "fooapp::bootstrap" recipe removes itself
from the runlist for that node like so

ruby_block "remove_bootstrap_recipe" do
block do
  Chef::Log.info("Removing fooapp boostrap from runlist")
  node.run_list.remove("recipe[fooapp::bootstrap]") if
node.run_list.include?("recipe[fooapp::bootstrap]")
end
action :create
end

This works fine but now it was always cumbersome to tell folks
"initially the runlist is THIS but afterwards the runlist will be
THAT". I've been thinking about ways to make this more data-driven.
The thought I was having is relying on something that I previously
maligned - bootstrapping nodes not saving until the complete run is
done. I'm thinking now I can leverage that functionality to include a
::bootstrap recipe from any cookbook.

Can anyone see any downsides in this? The general idea is something
like (in fooapp::default):

      existence = search("node", "name:#{node.name}")

      # Do some stuff that should always run/check

      # At the end of fooapp::default
      include_recipe "fooapp::bootstrap" if existence.size == 0

Does anyone see a problem with this? Is there a convenience method
that can tell me if I'm bootstrapping that I'm just not aware of?

Again, the end goal is to NOT need to specify the commensurate
"bootstrap" recipe for a given cookbook on setup.

Right now I'm actually dealing with a private cloud setup where I
don't have access to a userdata construct so I need to do some similar
to that, reload ohai and continue with the bootstrap. My concern is
accidentally calling node.save and having things blow up. I want this
to be as simple and durable as possible.

Thoughts?




Archive powered by MHonArc 2.6.16.

§