Running chef-client from another server and waiting for a result


#1

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#2

Yes, this certainly can be done – in fact, I’ll be doing the same thing in
just a few weeks.

What part of the process do you have questions about?
On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#3

Hi Charles,
Thanks for the reply…

What part of the process do you have questions about?
From serverA I want to tell serverB to run chef-client and tell
serverA when it’s done.

The notification bit can probably be done in the report handler
(somehow) but how do I tell serverB to start chef-client?

Cheers,
Edard

On Mon, Jul 4, 2011 at 5:48 PM, Charles Duffy charles@dyfis.net wrote:

Yes, this certainly can be done – in fact, I’ll be doing the same thing in
just a few weeks.

What part of the process do you have questions about?

On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#4

That depends on how paranoid you are about starting from a clean slate. :slight_smile:

In a past life, I did something like this with virtual machines, spinning up
a brand new guest with copy-on-write disk images for each instance. These
days, plenty of cloud providers give you a means to build a system from a
template set to run a prebuilt task on boot, and I might well end up doing
that. For physical hardware, you could use Cobbler to automate the process
of PXE-booting, installing a new OS, and then running the scripts of your
choice on that completely clean machine. If I can make this fit inside my
runtime constraints (PXE-booting an OS on modern physical hardware is
typically about 10 minutes, to give you a benchmark; copy-on-write image
spawning is basically instant; cloning a new cloud system from a prebuilt
image varies pretty wildly with your cloud provider), it’s what I’ll
probably do again this time.

Now, if you were using physical hardware (where you couldn’t do the
roll-back-to-snapshot thing) and didn’t want the delay of an OS reinstall or
the work of setting up a local copy-on-write filesystem… well, plenty of
ways to kick of chef-client.

That could be as easy as having your CI server have a SSH key in the
authorized_keys file on your test system, and a SSH command that kicks off
chef-client.

or… you could have your CI server commit to a git branch whenever your
prior code passes smoke testing, and have the test server poll that branch
or… you could have your CI tool do a git push to a branch local to the
test server, and a commit hook that takes actions resulting in chef-client
being spawned
or …have your git server spawn an action when that commit happens (github
has all kinds of hooks, down to AMQP or XMPP event publishing)

…etc. Sky’s the limit, use-your-imagination, etc.

On Mon, Jul 4, 2011 at 8:12 PM, Edward Sargisson esarge@pobox.com wrote:

Hi Charles,
Thanks for the reply…

What part of the process do you have questions about?
From serverA I want to tell serverB to run chef-client and tell
serverA when it’s done.

The notification bit can probably be done in the report handler
(somehow) but how do I tell serverB to start chef-client?

Cheers,
Edard

On Mon, Jul 4, 2011 at 5:48 PM, Charles Duffy charles@dyfis.net wrote:

Yes, this certainly can be done – in fact, I’ll be doing the same thing
in
just a few weeks.

What part of the process do you have questions about?

On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#5

Which tech stack you are using? Configure chef client as non daemon (i.e.
chkconfig chef-client off. service chef-client stop), and use your language
specific ssh library from ServerA to invoke chef-client --once on server
B. You can use tools like capistrano for doing such stuff (if you are
comfortable with ruby, or vanilla net/ssh library).
regards
ranjib

On Tue, Jul 5, 2011 at 6:42 AM, Edward Sargisson esarge@pobox.com wrote:

Hi Charles,
Thanks for the reply…

What part of the process do you have questions about?
From serverA I want to tell serverB to run chef-client and tell
serverA when it’s done.

The notification bit can probably be done in the report handler
(somehow) but how do I tell serverB to start chef-client?

Cheers,
Edard

On Mon, Jul 4, 2011 at 5:48 PM, Charles Duffy charles@dyfis.net wrote:

Yes, this certainly can be done – in fact, I’ll be doing the same thing
in
just a few weeks.

What part of the process do you have questions about?

On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#6

For the record, Seth Chisamore and I are working on something similar
using Noah and a modified Chef client that’s pokable over the network.
Right now I have working examples of doing gated chef-client runs on
bootstrap via Noah but nothing yet with already existing clients
unless they’re running in daemon mode.

On Tue, Jul 5, 2011 at 2:16 AM, Ranjib Dey ranjibd@thoughtworks.com wrote:

Which tech stack you are using? Configure chef client as non daemon (i.e.
chkconfig chef-client off. service chef-client stop), and use your language
specific ssh library from ServerA to invoke chef-client --once on server
B. You can use tools like capistrano for doing such stuff (if you are
comfortable with ruby, or vanilla net/ssh library).
regards
ranjib

On Tue, Jul 5, 2011 at 6:42 AM, Edward Sargisson esarge@pobox.com wrote:

Hi Charles,
Thanks for the reply…

What part of the process do you have questions about?
From serverA I want to tell serverB to run chef-client and tell
serverA when it’s done.

The notification bit can probably be done in the report handler
(somehow) but how do I tell serverB to start chef-client?

Cheers,
Edard

On Mon, Jul 4, 2011 at 5:48 PM, Charles Duffy charles@dyfis.net wrote:

Yes, this certainly can be done – in fact, I’ll be doing the same thing
in
just a few weeks.

What part of the process do you have questions about?

On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#7

A simple way to do that is to use knife ssh:
knife ssh “name:” “chef-client”

For full details see
http://wiki.opscode.com/display/chef/Knife#Knife-SSHSubcommand
This will basically ssh to the test machine, run chef-client and pipe the
results locally. when chef-client is done, this command will return.

On Mon, Jul 4, 2011 at 9:12 PM, Edward Sargisson esarge@pobox.com wrote:

Hi Charles,
Thanks for the reply…

What part of the process do you have questions about?
From serverA I want to tell serverB to run chef-client and tell
serverA when it’s done.

The notification bit can probably be done in the report handler
(somehow) but how do I tell serverB to start chef-client?

Cheers,
Edard

On Mon, Jul 4, 2011 at 5:48 PM, Charles Duffy charles@dyfis.net wrote:

Yes, this certainly can be done – in fact, I’ll be doing the same thing
in
just a few weeks.

What part of the process do you have questions about?

On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#8

The chef documentation is very bottom-up. It talks about nodes and roles and recipes and attributes and data bags. I think some more use-case driven documentation might help folks find their way around.

On Jul 6, 2011, at 3:10 PM, andi abes wrote:

A simple way to do that is to use knife ssh:
knife ssh “name:” “chef-client”

For full details see http://wiki.opscode.com/display/chef/Knife#Knife-SSHSubcommand
This will basically ssh to the test machine, run chef-client and pipe the results locally. when chef-client is done, this command will return.

On Mon, Jul 4, 2011 at 9:12 PM, Edward Sargisson esarge@pobox.com wrote:
Hi Charles,
Thanks for the reply…

What part of the process do you have questions about?
From serverA I want to tell serverB to run chef-client and tell
serverA when it’s done.

The notification bit can probably be done in the report handler
(somehow) but how do I tell serverB to start chef-client?

Cheers,
Edard

On Mon, Jul 4, 2011 at 5:48 PM, Charles Duffy charles@dyfis.net wrote:

Yes, this certainly can be done – in fact, I’ll be doing the same thing in
just a few weeks.

What part of the process do you have questions about?

On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward


#9

Have you looked at our “Build a FOO” series
http://help.opscode.com/kb/otherhelp ? There are several full stack
examples and a nagios quick start that show standing up actual
infrastructure. Build it, then dive in to see how Chef was used to
automate what you just did.

We’re definitely working on covering as many learning styles and
approaches as possible. It’s not an easy field(yet), infrastructure
automation! I’d love feedback on how this approach works for folks.

-a

Aaron Peterson aaron@opscode.com
Opscode Technical Evangelist

On Wed, Jul 6, 2011 at 13:17, Jeffrey E. Sussna jes@ingineering.it wrote:

The chef documentation is very bottom-up. It talks about nodes and roles and
recipes and attributes and data bags. I think some more use-case driven
documentation might help folks find their way around.
On Jul 6, 2011, at 3:10 PM, andi abes wrote:

A simple way to do that is to use knife ssh:
knife ssh “name:” "chef-client"
For full details
see http://wiki.opscode.com/display/chef/Knife#Knife-SSHSubcommand
This will basically ssh to the test machine, run chef-client and pipe the
results locally. when chef-client is done, this command will return.
On Mon, Jul 4, 2011 at 9:12 PM, Edward Sargisson esarge@pobox.com wrote:

Hi Charles,
Thanks for the reply…

What part of the process do you have questions about?
From serverA I want to tell serverB to run chef-client and tell
serverA when it’s done.

The notification bit can probably be done in the report handler
(somehow) but how do I tell serverB to start chef-client?

Cheers,
Edard

On Mon, Jul 4, 2011 at 5:48 PM, Charles Duffy charles@dyfis.net wrote:

Yes, this certainly can be done – in fact, I’ll be doing the same thing
in
just a few weeks.

What part of the process do you have questions about?

On Jul 4, 2011 7:34 PM, “Edward Sargisson” esarge@pobox.com wrote:

Hi all,
I am thinking of incorporating Chef into a continuous integration
server (in this case Bamboo but think Hudson/Jenkins).
I’d like to do a build, configure Chef properties for the new version,
then kick off chef-client on the test server. Once it’s done, I want
the script to know about it so that integration tests can be run
against it.

Is there a way to do this or am I using Chef beyond its purpose?

Thanks in advance,
Edward