Installing Chef Server with RVM

Chef is a systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.

The tutorials of install, and basic usage are written here.

I want to use it with RVM’s Ruby on Ubuntu Server 10.10.

RVM Installation

I use RVM with system wide install, whose instruction is here.
RVM: Ruby Version Manager – Installing RVM System Wide

chef-server# apt-get install curl git-core
chef-server# bash < <( curl -L http://bit.ly/rvm-install-system-wide )

Ruby 1.9.2 Installation

After installed RVM, you need to install Ruby 1.9.2 with RVM.

chef-server# apt-get install build-essential libssl-dev zlib1g-dev libreadline-dev
chef-server# source '/usr/local/lib/rvm'
chef-server# rvm install 1.9.2 -C --with-readline-dir=/usr --with-openssl-dir=/usr --with-zlib-dir=/usr

Bootstrap Chef-Server Installation

Now, you are prepared for installing Chef.
There is a nice tutorial for bootstrap installation of Chef-Server.
Bootstrap Chef RubyGems Installation – Chef – Opscode Open Source Wiki

Chef Solo Attributes Configuration

chef-server$ vi ~/chef.json
{
  "chef": {
    "server_url": "http://localhost:4000"
  },
  "run_list": [ "recipe[chef::bootstrap_server]" ]
}

Temporary PATH configuration

Before using Rubygems, you should set PATH configuration temporary, because I want to use chef to set all configurations.

chef-server# source '/usr/local/lib/rvm'
chef-server# rvm use 1.9.2
chef-server# gem install chef

Other Necessary Packages Installation

chef-server# apt-get install wget ssl-cert
chef-server# gem install chef

Chef Solo Installation

chef-server# mkdir -p /etc/chef
chef-server# vi /etc/chef/solo.rb

The content of “/etc/chef/solo.rb” is following.

file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"

You can use `chef-solo` command to install chef-server.

chef-server# chef-solo -c /etc/chef/solo.rb -j ~/chef.json -r http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz

chef-client, chef-server, chef-solr, chef-solr-indexer run script PATH configuration

Having finished installing, you will notice that chef-* fail to start on looking at logs “/etc/sv/chef-*/logs/main/current”.
The reason of this failure is that Ruby and Gems PATH are not set correctly, so you should set them like this.

chef-server# vi /etc/sv/{chef-client, chef-server, chef-solr, chef-solr-indexer}/run
- PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
---
+ export PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/rvm/gems/ruby-1.9.2-p0/bin
+ export GEM_HOME=/usr/local/rvm/gems/ruby-1.9.2-p0
+ export GEM_PATH=/usr/local/rvm/gems/ruby-1.9.2-p0

These chef processes are watched by “runit”, and after you rewrite them, all processes will start correctly.
If you want to start/stop/restart manually, use `/etc/init.d/chef-* {start/stop/restart}` command.

要は、PATH の設定だけちゃんとやっておけば RVM でインストールした Ruby でも Chef はインストールできますよということです。

References