Jenkins and Chef


#1

I’m trying to setup my existing RHEL Jenkins build slaves to orchestrate deploying and installing our product on multiple servers. I have a set of Jenkins jobs that deploy ProdA, and then a different, but similar, set of Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be running on the “same” build slave. However, ProdA may require a different set of cookbooks that ProdB. Therefore, my solution is to checkout the corresponding set of cookbooks for ProdA and ProdB, and since each job set runs on a different Jenkins $WORKSPACE directory, my cookbooks directory locations do not clash. I can then have the Jenkins jobs upload their cookbooks to the server - so far so good.

However, how do I orchestrate my knife.rb file to point to the corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the “same” build slave, meaning I’ll have one .chef/knife.rb file at any one time. I’m aware of the knife block plugin

Make sense?

Chris


#2

Are you using any sort of cookbook dependency management tool? (Berkshelf,
librarian, etc) If not, it sounds like adopting one of those tools and
installing/using it on Jenkins would greatly simplify your workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris Chris.Fouts@sensus.com
wrote:

I’m trying to setup my existing RHEL Jenkins build slaves to orchestrate
deploying and installing our product on multiple servers. I have a set of
Jenkins jobs that deploy ProdA, and then a different, but similar, set of
Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be running on the
“same” build slave. However, ProdA may require a different set of cookbooks
that ProdB. Therefore, my solution is to checkout the corresponding set of
cookbooks for ProdA and ProdB, and since each job set runs on a different
Jenkins $WORKSPACE directory, my cookbooks directory locations do not
clash. I can then have the Jenkins jobs upload their cookbooks to the
server – so far so good.

However, how do I orchestrate my knife.rb file to point to the
corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the
“same” build slave, meaning I’ll have one .chef/knife.rb file at any one
time. I’m aware of the knife block plugin

Make sense?

Chris


#3

Using berkshelf might greatly relieve your pain. Back in the day before
berks, I would accomplish this with a parameterized knife.rb. You can use
$WORKSPACE in your knife.rb. Here’s a snippet from an older project’s
knife.rb file, where I expected different cookbook paths based upon
different things going in different workspaces.

if File.exists?(File.join(ENV[‘WORKSPACE’], “chef-repo”))
cookbook_path ["#{ENV[‘WORKSPACE’]}/chef-repo/cookbooks"]
elsif File.exists?(File.join(ENV[‘WORKSPACE’], “cookbooks”))
cookbook_path ["#{ENV[‘WORKSPACE’]}/cookbooks"]
else
cookbook_path ["#{ENV[‘WORKSPACE’]}"]
end

So you can do things like that. But nowadays, I’d also recommend just
looking at berks.

George Miranda — Partner Engineering

512.481.2876 – gmiranda@getchef.com – Linkedin
http://www.linkedin.com/in/gmiranda23/ Twitter
https://twitter.com/gmiranda23

CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Blog
http://www.opscode.com/blog/ Facebook
https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef

Learn more about CHEF at re:Invent https://reinvent.awsevents.com/

Chef is an exclusive partner at the AWS Pop-Up Loft in SF
http://aws.amazon.com/start-ups/loft/

On Fri, Oct 24, 2014 at 2:20 PM, Dave Kichler dkichler@gmail.com wrote:

Are you using any sort of cookbook dependency management tool?
(Berkshelf, librarian, etc) If not, it sounds like adopting one of those
tools and installing/using it on Jenkins would greatly simplify your
workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris Chris.Fouts@sensus.com
wrote:

I’m trying to setup my existing RHEL Jenkins build slaves to
orchestrate deploying and installing our product on multiple servers. I
have a set of Jenkins jobs that deploy ProdA, and then a different, but
similar, set of Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be
running on the “same” build slave. However, ProdA may require a different
set of cookbooks that ProdB. Therefore, my solution is to checkout the
corresponding set of cookbooks for ProdA and ProdB, and since each job set
runs on a different Jenkins $WORKSPACE directory, my cookbooks directory
locations do not clash. I can then have the Jenkins jobs upload their
cookbooks to the server – so far so good.

However, how do I orchestrate my knife.rb file to point to the
corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the
“same” build slave, meaning I’ll have one .chef/knife.rb file at any one
time. I’m aware of the knife block plugin

Make sense?

Chris


#4

Chris,

I haven’t tried this yet but chef server replication might simplify things
for you:

This is however a Chef 12 feature.

I recently have been looking to build a jenkins server for chef (with
assumption of migrating to Chef 12) and using pipeline cookbook as a
starting point:

  • Phil

On Fri, Oct 24, 2014 at 5:56 PM, George Miranda gmiranda@getchef.com
wrote:

Using berkshelf might greatly relieve your pain. Back in the day before
berks, I would accomplish this with a parameterized knife.rb. You can use
$WORKSPACE in your knife.rb. Here’s a snippet from an older project’s
knife.rb file, where I expected different cookbook paths based upon
different things going in different workspaces.

if File.exists?(File.join(ENV[‘WORKSPACE’], “chef-repo”))
cookbook_path ["#{ENV[‘WORKSPACE’]}/chef-repo/cookbooks"]
elsif File.exists?(File.join(ENV[‘WORKSPACE’], “cookbooks”))
cookbook_path ["#{ENV[‘WORKSPACE’]}/cookbooks"]
else
cookbook_path ["#{ENV[‘WORKSPACE’]}"]
end

So you can do things like that. But nowadays, I’d also recommend just
looking at berks.

George Miranda — Partner Engineering

512.481.2876 – gmiranda@getchef.com – Linkedin
http://www.linkedin.com/in/gmiranda23/ Twitter
https://twitter.com/gmiranda23

CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Blog
http://www.opscode.com/blog/ Facebook
https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef

Learn more about CHEF at re:Invent https://reinvent.awsevents.com/

Chef is an exclusive partner at the AWS Pop-Up Loft in SF
http://aws.amazon.com/start-ups/loft/

On Fri, Oct 24, 2014 at 2:20 PM, Dave Kichler dkichler@gmail.com wrote:

Are you using any sort of cookbook dependency management tool?
(Berkshelf, librarian, etc) If not, it sounds like adopting one of those
tools and installing/using it on Jenkins would greatly simplify your
workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris Chris.Fouts@sensus.com
wrote:

I’m trying to setup my existing RHEL Jenkins build slaves to
orchestrate deploying and installing our product on multiple servers. I
have a set of Jenkins jobs that deploy ProdA, and then a different, but
similar, set of Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be
running on the “same” build slave. However, ProdA may require a different
set of cookbooks that ProdB. Therefore, my solution is to checkout the
corresponding set of cookbooks for ProdA and ProdB, and since each job set
runs on a different Jenkins $WORKSPACE directory, my cookbooks directory
locations do not clash. I can then have the Jenkins jobs upload their
cookbooks to the server – so far so good.

However, how do I orchestrate my knife.rb file to point to the
corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the
“same” build slave, meaning I’ll have one .chef/knife.rb file at any one
time. I’m aware of the knife block plugin

Make sense?

Chris


#5

Since we use SVN and not git, Berkshefl can’t help me.

From: Dave Kichler [mailto:dkichler@gmail.com]
Sent: Friday, October 24, 2014 5:21 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Jenkins and Chef

Are you using any sort of cookbook dependency management tool? (Berkshelf, librarian, etc) If not, it sounds like adopting one of those tools and installing/using it on Jenkins would greatly simplify your workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris <Chris.Fouts@sensus.commailto:Chris.Fouts@sensus.com> wrote:
I’m trying to setup my existing RHEL Jenkins build slaves to orchestrate deploying and installing our product on multiple servers. I have a set of Jenkins jobs that deploy ProdA, and then a different, but similar, set of Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be running on the “same” build slave. However, ProdA may require a different set of cookbooks that ProdB. Therefore, my solution is to checkout the corresponding set of cookbooks for ProdA and ProdB, and since each job set runs on a different Jenkins $WORKSPACE directory, my cookbooks directory locations do not clash. I can then have the Jenkins jobs upload their cookbooks to the server – so far so good.

However, how do I orchestrate my knife.rb file to point to the corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the “same” build slave, meaning I’ll have one .chef/knife.rb file at any one time. I’m aware of the knife block plugin

Make sense?

Chris


#6

Have you checked librarian, iirc it supports svn. Also it will be faster
and less buggy
On Oct 24, 2014 4:19 PM, “Fouts, Chris” Chris.Fouts@sensus.com wrote:

Since we use SVN and not git, Berkshefl can’t help me.

From: Dave Kichler [mailto:dkichler@gmail.com]
Sent: Friday, October 24, 2014 5:21 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Jenkins and Chef

Are you using any sort of cookbook dependency management tool?
(Berkshelf, librarian, etc) If not, it sounds like adopting one of those
tools and installing/using it on Jenkins would greatly simplify your
workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris Chris.Fouts@sensus.com
wrote:

I’m trying to setup my existing RHEL Jenkins build slaves to orchestrate
deploying and installing our product on multiple servers. I have a set of
Jenkins jobs that deploy ProdA, and then a different, but similar, set of
Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be running on the
“same” build slave. However, ProdA may require a different set of cookbooks
that ProdB. Therefore, my solution is to checkout the corresponding set of
cookbooks for ProdA and ProdB, and since each job set runs on a different
Jenkins $WORKSPACE directory, my cookbooks directory locations do not
clash. I can then have the Jenkins jobs upload their cookbooks to the
server – so far so good.

However, how do I orchestrate my knife.rb file to point to the
corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the
“same” build slave, meaning I’ll have one .chef/knife.rb file at any one
time. I’m aware of the knife block plugin

Make sense?

Chris


#7

It may be worth using git just to be able to use berkshelf. Look at svn2git to mirror your changes to svn.

Sent from my iPhone

On Oct 24, 2014, at 4:18 PM, Fouts, Chris Chris.Fouts@Sensus.com wrote:

Since we use SVN and not git, Berkshefl can’t help me.

From: Dave Kichler [mailto:dkichler@gmail.com]
Sent: Friday, October 24, 2014 5:21 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Jenkins and Chef

Are you using any sort of cookbook dependency management tool? (Berkshelf, librarian, etc) If not, it sounds like adopting one of those tools and installing/using it on Jenkins would greatly simplify your workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris Chris.Fouts@sensus.com wrote:
I’m trying to setup my existing RHEL Jenkins build slaves to orchestrate deploying and installing our product on multiple servers. I have a set of Jenkins jobs that deploy ProdA, and then a different, but similar, set of Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be running on the “same” build slave. However, ProdA may require a different set of cookbooks that ProdB. Therefore, my solution is to checkout the corresponding set of cookbooks for ProdA and ProdB, and since each job set runs on a different Jenkins $WORKSPACE directory, my cookbooks directory locations do not clash. I can then have the Jenkins jobs upload their cookbooks to the server – so far so good.

However, how do I orchestrate my knife.rb file to point to the corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the “same” build slave, meaning I’ll have one .chef/knife.rb file at any one time. I’m aware of the knife block plugin

Make sense?

Chris


#8

Adding git in the picture is NOT an option for us currently.

From: Daniel Condomitti [mailto:daniel@condomitti.com]
Sent: Friday, October 24, 2014 7:41 PM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Re: Jenkins and Chef

It may be worth using git just to be able to use berkshelf. Look at svn2git to mirror your changes to svn.

Sent from my iPhone

On Oct 24, 2014, at 4:18 PM, Fouts, Chris <Chris.Fouts@Sensus.commailto:Chris.Fouts@Sensus.com> wrote:
Since we use SVN and not git, Berkshefl can’t help me.

From: Dave Kichler [mailto:dkichler@gmail.com]
Sent: Friday, October 24, 2014 5:21 PM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: Jenkins and Chef

Are you using any sort of cookbook dependency management tool? (Berkshelf, librarian, etc) If not, it sounds like adopting one of those tools and installing/using it on Jenkins would greatly simplify your workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris <Chris.Fouts@sensus.commailto:Chris.Fouts@sensus.com> wrote:
I’m trying to setup my existing RHEL Jenkins build slaves to orchestrate deploying and installing our product on multiple servers. I have a set of Jenkins jobs that deploy ProdA, and then a different, but similar, set of Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be running on the “same” build slave. However, ProdA may require a different set of cookbooks that ProdB. Therefore, my solution is to checkout the corresponding set of cookbooks for ProdA and ProdB, and since each job set runs on a different Jenkins $WORKSPACE directory, my cookbooks directory locations do not clash. I can then have the Jenkins jobs upload their cookbooks to the server – so far so good.

However, how do I orchestrate my knife.rb file to point to the corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the “same” build slave, meaning I’ll have one .chef/knife.rb file at any one time. I’m aware of the knife block plugin

Make sense?

Chris


#9

I will check it out, thanks

From: Ranjib Dey [mailto:dey.ranjib@gmail.com]
Sent: Friday, October 24, 2014 7:36 PM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Re: Jenkins and Chef

Have you checked librarian, iirc it supports svn. Also it will be faster and less buggy
On Oct 24, 2014 4:19 PM, “Fouts, Chris” <Chris.Fouts@sensus.commailto:Chris.Fouts@sensus.com> wrote:
Since we use SVN and not git, Berkshefl can’t help me.

From: Dave Kichler [mailto:dkichler@gmail.commailto:dkichler@gmail.com]
Sent: Friday, October 24, 2014 5:21 PM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: Jenkins and Chef

Are you using any sort of cookbook dependency management tool? (Berkshelf, librarian, etc) If not, it sounds like adopting one of those tools and installing/using it on Jenkins would greatly simplify your workflow.

Dave

On Fri, Oct 24, 2014 at 1:59 PM, Fouts, Chris <Chris.Fouts@sensus.commailto:Chris.Fouts@sensus.com> wrote:
I’m trying to setup my existing RHEL Jenkins build slaves to orchestrate deploying and installing our product on multiple servers. I have a set of Jenkins jobs that deploy ProdA, and then a different, but similar, set of Jenkins jobs deploy ProdB. Both Jenkins job sets “can” be running on the “same” build slave. However, ProdA may require a different set of cookbooks that ProdB. Therefore, my solution is to checkout the corresponding set of cookbooks for ProdA and ProdB, and since each job set runs on a different Jenkins $WORKSPACE directory, my cookbooks directory locations do not clash. I can then have the Jenkins jobs upload their cookbooks to the server – so far so good.

However, how do I orchestrate my knife.rb file to point to the corresponding cookbook_path? Remember I’m doing two Jenkins job sets on the “same” build slave, meaning I’ll have one .chef/knife.rb file at any one time. I’m aware of the knife block plugin

Make sense?

Chris