[chef] Re: Trigger a chef client run after git push


Chronological Thread 
  • From: Peter Donald < >
  • To:
  • Subject: [chef] Re: Trigger a chef client run after git push
  • Date: Mon, 24 Sep 2012 18:07:49 +1000

Hi,

On Mon, Sep 24, 2012 at 5:40 PM, Karol Hosiawa < " target="_blank"> > wrote:
I've added a Jabber notification which sends a IM when any of our 80
apps is getting deployed/finished deploying so it helps a bit but I've been
thinking of a way to trigger a chef run on a node
immediately afer we git push a change to the application code so that we
don't have to wait.

I'm wondering if there's any tool in Chef that we could use to combine
git push hooks ( on our git server ) with restarting the chef client (to trigger
a deployment) on a node. The only thing that comes to mind is writing
a custom service that runs on every chef client node and listens for
"restart" events
and is able to restart chef client. Then writing a post git push hook
on the git server
that sends the "restart" even to the particular node.

 We do it through a couple of different mechanisms - however the simplest is simply a ssh in and run chef client. However we don't typically do it as a result of a push but instead do it as part of our jenkins infrastructure. Mostlywe use something that looks something like

def converge_linux_host(hostname)
      Net::SSH.start(hostname, self.username, :keys => [self.private_key_filename]) do |ssh|
        puts ssh.exec!("sudo service chef-client stop")
        puts ssh.exec!("sudo chef-client")
        puts ssh.exec!("sudo service chef-client restart")
      end
    end

HTH,

Peter Donald



Archive powered by MHonArc 2.6.16.

§