knife zero

This post introduces `knife-zero` as a way to bootstrap remote nodes with chef-zero style workflows. It explains the ssh tunneling behavior that solves socketless chef-zero bootstrap limitations in remote scenarios.

Coveros Staff

November 7, 2015

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]'
Coveros Staff

Coveros Staff

This post represents the collective insights of the Coveros team. Our staff consists of software experts who bring deep experience in secure agile development, DevOps, testing, and software quality. Over the past 20 years, Coveros has trained more than 30,000 professionals and worked with half of the Fortune 100 companies on mission-critical software development challenges. We draw on this extensive experience to share practical insights, proven strategies, and real-world solutions that help organizations build better software faster and more securely.