Dear Loyal Readers,

If you ever wish you could bootstrap a machine with chef-zero, but remotely, then knife-zero plugin is for you (aka: “do you ever wish Chef were more like Ansible?”).

Last week, I was trying to combine multiple knife commands: “-z” for using chef zero, and “bootstrap” for making a remote computer install chef-client first.  But, I kept getting the following error:

“No socketless chef-zero server on given port 8889”

It took me a while to realize that knife/chef-zero simply doesn’t work in this configuration [yet]. Thankfully, someone in the chef community has already made a plugin that adds this feature.  In this configuration, you can host your entire chef repository complete with cookbooks/roles/nodes/clients locally and still run chef-client on a remote node.  This plugin creates an ssh tunnel so that when chef-zero listens on the master node, and the remote node tries to http connect to itself, it actually tunnels back to the listening master node.

I installed it like this:

git clone https://github.com/higanworks/knife-zero
/opt/chef/embedded/bin/gem build knife-zero.gemspec
/opt/chef/embedded/bin/gem install  -l knife-zero-1.9.1.gem

And now it runs beautifully like this:

knife zero bootstrap -z remotehost -N remotehost -r 'role[Myrole]'

Until the Robots take the blue pill,
Jonathan Malachowski

Leave a comment

Your email address will not be published. Required fields are marked *

X