Just used Mike Hale’s drive-thru (http://github.com/mikehale/drive-thru/tree/master) to get a rails box up and running. The experience was worth persevering at - it will be much easier next time!
It required some non-documented things to get working out of the box:
some gems need to be installed
If you are not using slicehost (I was setting up a server on bytemark) then you need to disable the slicehost-specific setup_dns task (this seems to be the only one which is specific to slicehost)
- remove
'setup_dns', from the last line of the Rakefile
Also, if you are using the sample in the README for installing passenger (perhaps like me, robotically following them without understanding them (<— bad!)), there are a few minor (but confusing) typos:
- ‘Create site-cookbooks/applications/templates/default/rails.vhost.erb’ (note this should be .erb not .rb)
- ‘Add an applications cookbook to site-cookbooks’ (this apparently should be at the end - maybe this would have worked correctly if I hadn’t messed up on the first time)
I also amended the dna.rb to include:
:rails => {:version=> '2.3.2'},
:recipes => [
"apache2", "apache2::mod_rails",
"passenger",
"rails",
"git::minimal",
"mysql::server",
"mysql::gem",
'zsh',
'screen',
"applications"
]
I made my own versions of git::minimal (didn’t want the gitk installed on the server) and mysql::gem (although that weirdly didn’t work, and I ended up installing it manually on the server). I also did some manual stuff on the server (making a /var/www/apps/…/shared/config and shared/system and created the cookie_secret and database.yml - I guess I should have done that in a chef recipe too…
Hmm. Despite what I said, I did end up learning a little bit of chef.
looks like I did some stuff wrong. This sets up ready to deploy as root. This seems like an error, anyway, but additionally you want to make the ownership based on some other file, because Passenger does some clever user switching based on who owns /config/environment.rb (and they ought to be able to write to /log).
Additions within the files:
- add user to sudoers
I worked out how to do this in the mixture of dna.rb
:authorization => { :sudo=> {:users=>[USERNAME], :groups=>['admin']},
- UPDATE: I worked out how to make the users default directory and ensure the correct perms for it and .ssh:
directory "/home/#{name}" do
owner name<
group name
mode 0755 #rwx-r-xr-x
end
file "/home/#{name}/.ssh/authorized_keys" do
owner name
group name
mode 0644 #rw-r--r--
end
directory "/home/#{name}/.ssh" do
owner name
group name
mode 0700 #rw-r--r--
end
- Other additions (tricky to do in chef):
add key to deployment user
sudo cp -pR /root/.ssh/authorized_keys ~USER/.ssh
sudo chown -R USER:USER ~USER/.ssh