Skip to content

How to setup local development environment for Chef with a Jenkins pipeline example

Notifications You must be signed in to change notification settings

ncjohnson/local_chef_dev_setup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Local Development Setup for Chef

Download and install

chef-dk - Does not currently support Windows or Mac OSX earlier than Mavericks

virtual box

vagrant

If you are not able to run chef-dk check out this blog post by Mischa Taylor:

Set Up a Sane Ruby Cookbook Authoring Environment for Chef on Mac OS X, Linux and Windows

You may want to set the embedded ruby shipped with Chef first in your PATH

echo 'export PATH="/opt/chefdk/embedded/bin:$PATH"' >> $HOME/.bash_profile

Make sure ruby and bundler are installed and working

which ruby && ruby -v

which bundle && bundle -v

Install kitchen-vagrant gem if not already present

chef gem install kitchen-vagrant

Local cookbook development workflow

create new cookbook using Berkshelf

berks cookbook pipeline

list test-kitchen VM's

cd pipeline

add jenkins dependency to metadata.rb

depends 'jenkins'

use Berkshelf to download dependency cookbooks

berks install

Add jenkins to recipes/default.rb to create a jenkins master

and also install java

include_recipe 'jenkins::java'

include_recipe 'jenkins::master'

Modify .kitchen.yml to add default recipe and attribute

suites:
  - name: default
    run_list: pipeline::default
    attributes:
      jenkins:
        master:
          install_method: package

Modify .kitchen.yml to add cpu/memory and port forwarding for jenkins

driver_config:
  network:
  - ["forwarded_port", {guest: 8080, host: 8080}]
  customize:
    memory: 2048
    cpus: 2

Show all kitchen instances

kitchen list

Run VM for CentOS 6.5 and converge with configuration

kitchen converge centos

See if jenkins is running

http://localhost:8080

see git status of files added and modified

git status

add all files

git add .

commit all changes

git commit -m "initial commit of pipeline cookbook"

Links to example cookbook

Pipeline Cookbook Example

About

How to setup local development environment for Chef with a Jenkins pipeline example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published