Skip to content

Instantly share code, notes, and snippets.

Last active March 15, 2017 14:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Initial setup to get chef-client running on raspbian
: <<'END' # Block comment
Use this script to prepare a clean raspbian image to run chef-client
Do not forget to add an empty file named "ssh" on the "boot" partition of your raspbian image to enable the ssh daemon.
If you did not run ssh-keygen before on your host machine, please do so before running this script.
This script sets up the debian testing packages as ruby 2.3 is currently not available in jessy. It also adds a pinning entry so packages available in jessy are preferred.
Afterwards it installs the chef gem and we are ready to bootstrap our new node :)
if [ $# -ne 1 ]; then
echo "usage: $0 ip_address"
sshpass -V > /dev/null
if [ $? -ne 0 ]; then
sudo apt install sshpass
#delete old keys (from former trials :) ) from your known_hosts file
ssh-keygen -f "~/.ssh/known_hosts" -R $ip
#add our key to the raspberry without it requesting a password
sshpass -p $pw ssh-copy-id -o "StrictHostKeyChecking no" $username@$ip
# This is where the fun begins
ssh $username@$ip <<ENDSSH
echo "$pw" | sudo -S ls #trigger sudo password entry
sudo -i
echo "deb testing main contrib non-free rpi" | tee -a /etc/apt/sources.list
echo -e "Package: *\nPin: release a=testing\nPin-Priority: 400\n" | tee -a /etc/apt/preferences.d/testing
apt-get update
echo "Updating time"
apt-get -y install ntp ntpdate
service ntp stop
ntpdate -s
service ntp start
echo "Installing ruby"
apt-get install -t testing -y ruby-dev
echo "Installing chef"
gem install chef
#echo " chef-server.test" | tee -a /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment