Portage overlay to install chef
Switch branches/tags
Nothing to show
Pull request Compare This branch is even with veszig:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Portage overlay for Chef.

This is a work in progress, please submit patches or pull requests.

The net-misc/rabbitmq-server ebuild comes from Kenneth Kalmer's portage overlay. The config files are from the Opscode debian packages.

Client setup

To use this overlay, pull it down via GIT or download the tarball and add it to PORTDIR_OVERLAY in your make.conf. You will probably need to add some package.keywords for the various packages to be able to install them.

# clone the GIT repository
git clone git://github.com/veszig/chef-overlay.git /usr/local/chef-overlay

# OR download the tarball
mkdir /usr/local/chef-overlay && wget -q -O - \
  http://github.com/veszig/chef-overlay/tarball/master | \
  tar xz --strip 1 -C /usr/local/chef-overlay

# add the overlay to your make.conf
cat >> /etc/make.conf <<\EOF
# for virtual/jdk
# for app-admin/chef* and dependencies
PORTDIR_OVERLAY="${PORTDIR_OVERLAY} /usr/local/chef-overlay"

# create /etc/portage/package.keywords directory
if [ -f /etc/portage/package.keywords ] ; then
  mv /etc/portage/package.keywords /etc/portage/package.keywords_
  mkdir /etc/portage/package.keywords
  mv /etc/portage/package.keywords_ /etc/portage/package.keywords/misc
elif [ ! -d /etc/portage/package.keywords ] ; then
  mkdir /etc/portage/package.keywords

# chef-client and dependencies
cat >> /etc/portage/package.keywords/chef <<\EOF

Now you should be able to install the Chef client.

emerge chef

You may start using chef-solo or edit /etc/chef/client.rb (at least edit chef_server_url) and start the client with it's init script.

rc-update add chef-client default
/etc/init.d/chef-client start

You will need to create the client in the server and copy it's cert to /etc/chef/client.pem or copy the server's validation.pem to /etc/chef and let the client register itself.


The server part is a bit more work:

# chef-server and dependencies
cat >> /etc/portage/package.keywords/chef-server <<\EOF

emerge chef-server

This will install CouchDB and RabbitMQ but you still need to create a RabbitMQ vhost and user for Chef:

/etc/init.d/rabbitmq start
AMQP_PASS=$(dd if=/dev/urandom count=50 2>/dev/null | md5sum | awk '{print $1}')
rabbitmqctl add_vhost /chef
rabbitmqctl add_user chef ${AMQP_PASS}
rabbitmqctl set_permissions -p /chef chef ".*" ".*" ".*"
echo "amqp_pass '${AMQP_PASS}'" >> /etc/chef/server.rb
echo "amqp_pass '${AMQP_PASS}'" >> /etc/chef/solr.rb
#mkdir -m 0700 ~/private/ && echo ${AMQP_PASS} > ~/private/chef_amqp_pass

Start the server:

rc-update add chef-server-api default
/etc/init.d/chef-server-api start

You should be able to connect to port 4000 and get a nice 401 Unauthorized error from merb (congratulations!).

You can now start using Chef-server with knife or install the web interface (if you emerged chef-server with the webui USE flag, you already have this installed):

emerge chef-server-webui

Edit web_ui_admin_default_password in /etc/chef/webui.rb and start it:

rc-update add chef-server-webui default
/etc/init.d/chef-server-webui start

You can connect to port 4040 and log in with user admin.


You may also want to install Fog a library that knife uses to interact with cloud providers.

# fog and dependencies
cat >> /etc/portage/package.keywords/fog <<\EOF

emerge fog

Be aware, that currently knife is only able too bootstrap ubuntu cloud servers (if you want to use gentoo servers, you may write your custom script with fog).