Pither.com / Simon
Development, systems administration, parenting and business

Migrating Chef to a new server

The Opscode wiki only provides some rather vague and incomplete hints for migrating Chef to a new server. Below is what I actually did and it worked for me. This is all running on Debian Squeeze and using Chef 0.10.8 from the Opscode provided Debian packages.

On the new server:

apt-get install chef-server
/etc/init.d/chef-server-webui stop
/etc/init.d/chef-server stop
/etc/init.d/chef-expander stop
/etc/init.d/chef-solr stop
/etc/init.d/rabbitmq-server stop
/etc/init.d/couchdb stop

On the old server:

curl -H "Content-Type: application/json" -X POST http://localhost:5984/chef/_compact
/etc/init.d/chef-server-webui stop
/etc/init.d/chef-server stop
/etc/init.d/chef-expander stop
/etc/init.d/chef-solr stop
/etc/init.d/rabbitmq-server stop
/etc/init.d/couchdb stop

tar -czf /tmp/chef_server_export.tar.gz /var/lib/chef /etc/chef /etc/couchdb /var/lib/couchdb

Transfer the resulting file from the old machine to the new one (eg via scp, rsync, etc).

Be careful with this next bit - these commands will overwrite existing data on the new server! So with that warning in mind and back on the new machine, with the above tar file now transferred into /tmp/...

cd /
tar -xzf /tmp/chef_server_export.tar.gz
/etc/init.d/couchdb start
/etc/init.d/rabbitmq-server start
/etc/init.d/chef-solr start
/etc/init.d/chef-expander start
/etc/init.d/chef-server start
/etc/init.d/chef-server-webui start

On you workstation edit your .chef/knife.rb file and update the chef_server_url line so it points to your new server. Then run:

knife node list

Just to check you get the right list back from the new server.

Then update the DNS entry for your chef hostname (hopefully you do have a name just used by chef!) and all your clients should catch up as DNS filters through.

Add a comment