Chef Client Installation On CentOS 5.4

| No TrackBacks

Set up some variables we'll use throughout the install

BASEARCH=$(uname -i)

We need a newer version of Ruby than provided by CentOS/RHEL. Add appropriate repositories and install the packages.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/$BASEARCH/epel-release-5-3.noarch.rpm
rpm -Uvh http://download.elff.bravenet.com/5/$BASEARCH/elff-release-5-3.noarch.rpm
yum install -y ruby ruby-shadow ruby-ri ruby-rdoc gcc gcc-c++ ruby-devel

With that complete, we want to install RubyGems from source as it's cross-platform and we know what to expect.

cd /tmp
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
tar zxf rubygems-1.3.6.tgz
cd rubygems-1.3.6
ruby setup.rb
ln -sfv /usr/bin/gem1.8 /usr/bin/gem  # We may need this symlink if /usr/bin/gem doesn't exist

Make sure the rubygems EXECUTABLE_DIRECTORY is in our PATH

# gem env && echo -e "\nPath: $PATH"
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.6
  - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby18
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /home/ymek/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
Path: /usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.3.4:/usr/games/bin:/home/ymek/development/sdks/flex_3.2/bin

Create some config files to get chef-solo up and running

# cat /root/solo.rb
file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"
recipe_url "http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz"
# cat /root/chef.json
{
    "bootstrap": {
        "chef": {
            "url_type": "http",
	    "init_style": "init",
	    "path": "/opt/lib/chef",
	    "serve_path": "/opt/lib/chef",
            "server_fqdn": "chef.server.com"  # need a fqdn
        }
    },
    "run_list": [ "recipe[bootstrap::client]" ]
}

Add the Opscode gem source

gem sources -a http://gems.opscode.com

Install the chef gem. This will also pull in some dependencies.

gem install chef

Bootstrap the client using Opscode's recipe.

# /usr/bin/chef-solo -c /root/solo.rb -j /root/chef.json

Copy your server's validation.pem to /etc/chef/ on the client. It's located in /etc/chef/validation.pem by default. We also need to copy the init scripts over.

cp /usr/lib64/ruby/gems/1.8/gems/chef-0.8.10/distro/redhat/etc/init.d/chef-client /etc/init.d/

EDIT: The 0.8.10 release has an incorrect path for the chef-client pid file. Let's fix that.

/bin/sed -i '/\/var\/run\/chef\/client\.pid/\/var\/run\/chef\/chef-client\.pid/' /etc/init.d/chef-client

Make the script executable and add it to the runtime services.

chmod +x /etc/init.d/chef-client
chkconfig -a chef-client
chkconfig chef-client on

The client will request validation from the server upon first run. This will generate a client-specific key and save it to /etc/chef/client.pem. After this happens, delete /etc/chef/validation.pem from the client machine

No TrackBacks

TrackBack URL: http://mykestubbs.com/mt/mt-tb.cgi/13

About this Entry

This page contains a single entry by Myke published on April 9, 2010 5:12 PM.

Chef Server Installation On CentOS 5.4 was the previous entry in this blog.

Find recent content on the main index or look in the archives to find all content.