Centos6 : Chef Node Creation

I thought I’d share the scripts I use to take a fresh Centos6 install and have it configured to work with a Chef server. Maybe its not as easy as when running in a virtualized environment, but it saves plenty of time.

On the new node I run the setup_client.sh script which calls in the end client_gen.sh on the Chef server once everything is installed on the node. I left the version numbers for Ruby and Chef in the script so you know what versions I’ve tested this with.



sudo rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm

sudo yum update

sudo yum install ruby ruby-shadow ruby-ri ruby-rdoc gcc gcc-c++ ruby-devel ruby-static

cd /tmp
wget http://production.cf.rubygems.org/rubygems/rubygems-$RUBY_VSN.tgz
tar zxf rubygems-$RUBY_VSN.tgz
cd rubygems-$RUBY_VSN
sudo ruby setup.rb --no-format-executable

sudo gem install chef -v $CHEF_VSN 

mkdir ~/.chef

cat > ~/.chef/knife.rb <<EOF log_level :info log_location STDOUT node_name '$NODE' client_key '/home/$USER/.chef/$NODE.pem' validation_client_name 'chef-validator' validation_key '/etc/chef/validation.pem' chef_server_url '$CHEF' cache_type 'BasicFile' cache_options( :path => '/home/$USER/.chef/checksums' ) EOF

ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub $CHEF_IP

ssh $CHEF_IP "yes | knife client delete $NODE"
ssh $CHEF_IP "yes | /home/$CHEF_USER/client_gen.sh $NODE"
scp $CHEF_IP:/tmp/$NODE ~/.chef/$NODE.pem


knife client create $1 -n -a -f /tmp/$1
knife node create $1 --no-editor

5 thoughts on “Centos6 : Chef Node Creation

    • reality is that if you get a good rails developer they cost is nelbigilge compared to the productivity and quality. It’s been my experience that rails devs care more often about the final product. Just my opinion, no survey’s or stats to back it up.

  1. Cedric,I’m trying to orgianze an ALT.Dev patterns, practices, tools and agile open spaces conference in Boston (next spring) of a kind that was never done before how about combining Alt.Net and Java architects and developers to talk about these topics? All in all we do the same things and there is no reason to have 2 fighting camps.Will you be interested in participating in such an event? Shoot me an e-mail for more details (I don’t have your direct e-mail).

  2. great submit, very informative. I’m wondering why the other experts of this sector do
    not realize this. You must proceed your writing.
    I’m confident, you have a great readers’ base already!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s