Chef doesn't offer a omnibus chef-client
for raspberry pi yet. This knife bootstrap
script helps get around that by offering you a few methods to get a Raspberry Pi ready chef-client.
There are bootstrap scripts to support both raspbian-wheezy
and raspbian-jessie
. The commands below replace the release codename with the OS running on your Raspberry Pi. If for some reason you do not wish to run ssh
in the subshell, just replace it manually.
For example: Replace <lsb_codename_here>
in raspbian-<lsb_codename_here>-gems.erb
with the output of lsb_release -c -s
on your Pi.
Before you start check the following:
- your chef workstation environment is setup and ready with
knife
- your pi is on the network and you can login as root
- have some patience - this will take a while - especially the ruby-build route
This script has been tested against raspbian-wheezy
, and raspbian-jessie
but should likely work gracefully for other Debian-based Linux systems.
The older raspbian-wheezy will use ruby-build to build a ruby and then install chef into /opt/chef. This will take a long time
The raspbian-jessie has some options to get ruby and chef: compile with ruby-build, prebuilt bundle, or adding a new apt repository to get ruby2.3. The default is my to build it. Prefix your knife bootstrap
like OPT=prebuilt knife bootstrap
with the following options:
OPT=build
- Default: Uses ruby-build to build a new ruby- Slow: This will take a long time
OPT=prebuilt
- Same as above, only it comes from a prebuilt tar.gz bundle by dayne.- Fast: Only do this if you are Dayne or trust me
OPT=stretch
- Adds the stretch apt repository to pi and installs ruby-2.3 from apt- Fast: Do this if you don't mind new apt repo on your pi
knife bootstrap -t raspbian-$(ssh root@<address_of_your_pi> \
'lsb_release -c -s')-gems.erb -x root address_of_your_pi
Or to sudo in via pi user if you don't have root access
knife bootstrap -t raspbian-$(ssh root@<address_of_your_pi> \
'lsb_release -c -s')-gems.erb --ssh-user pi --sudo address_of_your_pi
ruby-build
installed in/usr/local/bin
/opt/chef
with a ruby (wheezy: 2.2
,jessie: 2.3
) compiled fromruby-build
- Or possibly ruby from stretch repo if you choose that option for jessie.
- pi's clock will be synchronized and pi running
ntpd
(network time protocol daemon). /usr/local/bin/chef-client
to runchef-client
with right path for Chef &ruby
.
Note: I have a short attention span and waiting for ruby to compile on a pi is boring. You have option of using my prebuilt /opt/chef
if you want using that OPT=prebuilt
flag on the jessie bootstrap.
A full on example of a knife
command that applies a Chef recipe. Using my own d-base recipe and taking advantage of my pre-built /opt/chef
OPT=prebuilt knife bootstrap -t raspbian-jessiegems.erb -u pi -x \
-N NODE_NAME --run-list 'recipe[d-base::default]' ADDRESS_OF_PI
- @tinoschroeter : Tino Schröter as original author
- @dayne : dayne updated and evolved to support Chef 12
- @in-bto : ino-bto for trusted certs forwarding to client node
- @Edubits: Edubits updated to Jessie
- @trinitronx: trinitronx Merged support for both Wheezy and Jessie
- @marcusbooyah: marcusbooyah Tested and fixed bugs in
OPT=stretch