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

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

Autoloading Facebook's PHP Classes

| No TrackBacks

Being the lead developer of ShareSong has given me a chance to become fairly familiar with Facebook's PHP client library. From the moment I began using the library I had one major complaint: cludgy integration.

We use an autoloader within our PHP frameworks to instantiate objects without manually requiring every class file. As such, I can include my conf.php and create a new Facebook(FB_APIKEY, FB_SECRET); and php can magically figure out that class is within a file called Facebook.php within a specified lib directory. Well, the Facebook platform's client library bundles several (albeit-related) classes into one file, they do not follow our mechanism of ProudCamels for classes, and otherwise make things messy.

Well, being me I decided to "fix" it. So, here it is. Extract it, pop it into your app's library directory and viola! A library client that autoloads and is, beyond some case changes to class-names and restructuring, a completely Facebook-authored PHP client!
Facebook-Platform.tar.gz

Grooveshark 2.0

| No TrackBacks

Grooveshark 2.0 is coming. Here's a taste. =)
gs_screen01.png

Grooveshark Dev

| No TrackBacks

For the last few months, I have been working with Escpae Media Group; a young company whose flagship product is Grooveshark. It's very exciting to be a part of such a wonderful and youthful team. We're going places, and you should all come with us.

How the mighty have fallen

| No TrackBacks

Not only have we polluted this planet, we've cluttered the atmosphere surrounding it. Call me a hippie, but wtf?

Parallel?

| No TrackBacks

I wonder what Hillary was thinking when she decided to liken herself to Rocky in Philadelphia. In this BBC News article Senator Clinton is quoted: "When it comes to finishing a fight, Rocky and I have a lot in common. I never quit." The determination is admirable. Let us not forget: Rocky lost.

Sound Blaster Audigy LS and Linux

| No TrackBacks

I am a Gentoo user and, as such, have had some troubles in the past getting my sound cards to work with 5.1 sound. However those days have come to a close!

Configure/make/install a kernel and configure alsa in accordance with the Gentoo Linux ALSA Guide. Configuration is fairly simple and mostly follows standard kernel build procedures; don't forget to update your modules. Reboot into this new kernel. At this point, Audacious was throwing an error upon startup. After multiple, unsuccessful attempts at fixing this problem, I gave up; sound was working and software volume is what I desired anyway. A few days later, I revisited the issue and tried to load the sound driver for the Audigy LS (ca0106 chipset)

modprobe snd-ca0106

With all mixer devices properly configured, I moved on to 5.1 sound. This has been excruciatingly painful in the past. However, Gentoo proves worthwhile again (at least in documentation ;) with their Linux Surround Sound Howto. I also found the information in this surround sound reference valuable. Adding the proper bits of code listed in the Gentoo howto to my .asoundrc, I now have 5.1 sound in Linux. woot!