March 2010 Archives

Chef Server Installation On CentOS 5.4

| No TrackBacks

Here at Grooveshark, we need to manage various types of servers with a varying set of dependencies and installed software suites (apache, mysql, hadoop, sphinx, etc). Here's how we got Chef up and running. All of the commands below assume root privileges.

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/i386/epel-release-5-3.noarch.rpm
rpm -Uvh http://download.elff.bravenet.com/5/i386/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.6 (2008-08-11 patchlevel 287) [i386-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /root/.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/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Add the Opscode gem source

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

Now we can install the chef gem. This pulls in all gem dependencies as well.

gem install chef

The current release of merb (1.1.0) doesn't play nice with Chef. Downgrade to a version which does (1.0.15)

gem install merb-core merb-assets merb-haml merb-helpers merb-param-protection merb-slices -v=1.0.15
gem uninstall -I merb-core merb-assets merb-haml merb-helpers merb-param-protection merb-slices -v=1.1.0

Now that we have the basic framework in place, we'll use the Opscode cookbooks to handle setting up the rest of the server configuration. We need to populate two files to make this happen. Other attributes of interest can be found in the bootstrap README

# 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": "spacewalk.in.escapemg.com",
      "webui_enabled": true
    }
  },
  "run_list": [ "recipe[bootstrap::server]" ]
}

The server should now know how to behave in a limited capacity. We want to bring in the external recipe tarball. This will bring up the Chef Server environment.

chef-solo -c ~/solo.rb -j ~/chef.json 

We want to make sure we're using the proper validator before firing everything up. edit /etc/chef/server.rb and make sure "validate_client_name" is set to "chef-validator"

Now, copy some default configurations over, register services that go with them, and start everything up.

useradd chef
chown chef:chef -R /srv/chef
chown -Rv chef:chef /etc/chef/
chown -Rv chef:chef /var/chef/ca/
cp /usr/lib/ruby/gems/1.8/gems/chef-0.8.0/distro/redhat/etc/sysconfig/* /etc/sysconfig
cp /usr/lib/ruby/gems/1.8/gems/chef-0.8.0/distro/redhat/etc/init.d/* /etc/init.d
chmod +x /etc/init.d/chef-*

for svc in solr solr-indexer server server-webui
do
  chmod +x /etc/init.d/chef-${svc}
  chkconfig --add chef-${svc}
  chkconfig chef-${svc} on
  service chef-${svc} start
done

About this Archive

This page is an archive of entries from March 2010 listed from newest to oldest.

December 2009 is the previous archive.

April 2010 is the next archive.

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