As I mentioned before, Chef appears to work well on mostly Debian and Ubuntu. You will have to do a bit more work on the other OSes: In the case of FreeBSD, a lot more.

Here is one example: The recipe chef-client is used to install startup scripts on the nodes (rc scripts for Red Hat, upstart for Ubuntu, etc). it works on most OSes - except for BSD systems. In fact, in the code, when it noticed it is on a BSD systems, it puts out the following:

when "bsd"
  log "You specified service style 'bsd'. You will need to set up your rc.local file."
  log "Hint: chef-client -i #{node["chef_client"]["client_interval"]} -s #{node["chef_client"]["client_splay"]}"
  
else
  log "Could not determine service init style, manual intervention required to start up the chef-client service."
end

in other words, it doesn’t even bother.

I am not sure if it is out of laziness or just having limited resources that they didn’t create rc scripts for BSD (I could understand OpenBSD, but FreeBSD?), so I created the following rc script:

#!/bin/sh

# PROVIDE: chef
# REQUIRE: LOGIN
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="chef"
rcvar=`set_rcvar`
stop_cmd="chef_stop"
command="/usr/local/bin/${name}-client"
command_args="-i -s -d -L /var/log/chef/client.log -c /etc/chef/client.rb -P /var/run/chef.pid"
load_rc_config $name
export rc_pid
chef_stop()
{
	pidfile="/var/run/chef.pid"
	rc_pid=`cat ${pidfile}`
        kill $rc_pid
}

run_rc_command "$1"

Ordinarily, I shouldn’t have to create a separate function to kill a chef process, but for some reason, the rc functions within FreeBSD can’t find the PID. 

Interestingly enough, during my debugging with the script, through the use of truss I found an undocumented feature where instead of adding the entry to enable a service in /etc/rc.conf, you can put it in /etc/rc.conf.d - which is what I did:

freebsd82# pwd
/etc/rc.d
freebsd82# cd ../rc.conf.d
freebsd82# ls
chef
freebsd82# cat chef
chef_enable="YES"


Apparently it came from NetBSD

With that, I got a working chef init script. Now to see if I can update the chef-client recipe and working on FreeBSD.