I got my Raspberry PI Starter Kit this week. The Kit is very nice, as it comes packaged with everything you need in order to get your PI up and running ASAP. Just plugin the SD-Card, connect Ethernet cable and USB Power supply and your ready to go!
Booting Up
After the PI has booted from the provided Image on the SD-Card, it is accessible through SSH:
1 | ssh pi@10.0.1.2 |
ssh pi@10.0.1.2
It’s a good idea to copy the SSH public key to the machine, so that you do not have to type in the passphrase everytime:
1 2 | ssh pi@10.0.1.2 "mkdir -p .ssh" scp ~/.ssh/id_dsa.pub pi@10.0.1.2:.ssh/authorized_keys |
ssh pi@10.0.1.2 "mkdir -p .ssh" scp ~/.ssh/id_dsa.pub pi@10.0.1.2:.ssh/authorized_keys
When the provided Raspberry PI distro is outdated, you can update it with the builtin admin tool:
1 2 3 | sudo raspi-config => select update, exit sudo reboot |
sudo raspi-config => select update, exit sudo reboot
Bootstrap for Puppet
As an experiment, I wanted to provision my PI with Puppet. Since the PI comes packaged with Python as a programming language, you need to install Ruby in order to run Puppet.
There are several Ruby Versions available as Debian packages, but I wanted to try out RBenv just for fun. This is only an option if you have plenty of time, cause building a Ruby from source takes round about 2 hours…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # update aptitude sudo apt-get update -y # install some basics like git and support for ruby to compile and puppet to work sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline-dev git-core curl libyaml-dev -y # clone the rbenv repo and setup the env git clone git://github.com/sstephenson/rbenv.git ~/.rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile echo 'eval "$(rbenv init -)"' >> ~/.profile exec $SHELL -l # add the ruby-build plugin and install a ruby 1.9.3 git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build rbenv install 1.9.3-p327 # set the ruby as the global ruby version rbenv global 1.9.3-p327 rbenv rehash # check if it's working fine ruby -v # add the rbenv sudo plugin git clone git://github.com/dcarley/rbenv-sudo.git ~/.rbenv/plugins/rbenv-sudo |
# update aptitude sudo apt-get update -y # install some basics like git and support for ruby to compile and puppet to work sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline-dev git-core curl libyaml-dev -y # clone the rbenv repo and setup the env git clone git://github.com/sstephenson/rbenv.git ~/.rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile echo 'eval "$(rbenv init -)"' >> ~/.profile exec $SHELL -l # add the ruby-build plugin and install a ruby 1.9.3 git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build rbenv install 1.9.3-p327 # set the ruby as the global ruby version rbenv global 1.9.3-p327 rbenv rehash # check if it's working fine ruby -v # add the rbenv sudo plugin git clone git://github.com/dcarley/rbenv-sudo.git ~/.rbenv/plugins/rbenv-sudo
Having a running Ruby, installing Puppet is just a matter of minutes, as it is distributed as a Ruby Gem. It’s a good idea though to disable RDoc and RI documentation generation to speed up the installation:
1 2 3 4 5 6 7 8 9 10 | # puppet needs it's own user and group sudo useradd --comment "Puppet" --no-create-home --system --shell /bin/false puppet # disable documentation generation for gems echo "gem: --no-ri --no-rdoc" > ~/.gemrc # install the gem gem install puppet # make puppet executables available through rbenv rbenv rehash # check if facter is installed properly facter |
# puppet needs it's own user and group sudo useradd --comment "Puppet" --no-create-home --system --shell /bin/false puppet # disable documentation generation for gems echo "gem: --no-ri --no-rdoc" > ~/.gemrc # install the gem gem install puppet # make puppet executables available through rbenv rbenv rehash # check if facter is installed properly facter
If facter complains about a problem with the fact fqdn, just add a real hostname to /etc/hosts:
1 | sudo vi /etc/hosts |
sudo vi /etc/hosts
127.0.1.1 raspberrypi.nofail.de raspberrypi
First Puppet run
After that puppet should run without warnings and you can start writing the first manifest:
1 2 3 | mkdir /home/pi/puppet cd /home/pi/puppet vi base.pp |
mkdir /home/pi/puppet cd /home/pi/puppet vi base.pp
Add this to base.pp to install VIM to the Raspberry PI:
package { "vim":
ensure => installed,
}
This manifest can be applied with rbenv sudo:
1 | rbenv sudo puppet apply base.pp |
rbenv sudo puppet apply base.pp
Et voila, VIM is installed on your PI.
Samba
Working with the tools on my Mac is cool, so sharing a directory on the PI is a nice way of editing locally and running stuff on the server. Deriving from a basic installation of Samba that’s what needs to be done on the PI:
1 2 3 4 | # install samba sudo apt-get install samba samba-common-bin # update config sudo vi /etc/samba/smb.conf |
# install samba sudo apt-get install samba samba-common-bin # update config sudo vi /etc/samba/smb.conf
In /etc/samba/smb.conf uncomment line security = user and add the following section:
[Puppet] comment = Puppet share path = /home/pi/puppet writeable = yes guest ok = no
Once you did this, add a Samba user and restart the service:
1 2 3 4 5 6 | # make shared dir writable chmod 777 /home/pi/puppet # add the user for access over smb sudo smbpasswd -a pi # restart smb sudo /etc/init.d/samba restart |
# make shared dir writable chmod 777 /home/pi/puppet # add the user for access over smb sudo smbpasswd -a pi # restart smb sudo /etc/init.d/samba restart
Using ⌘+k on the Mac connects to a remote server. Enter smb://pi@10.0.1.2 and connect to the Puppet share. You can now access your files via open /Volumes/Puppet/.
DynDNS
In order to access the PI over the internet, subscribing to a free Dynamic DNS service like NO-IP is a nice way to get a static hostname for name resolution.
NO-IP has some Tools available for download that help you keeping the switching IP up to date. Since the provided binaries did not work on the PI, the NO-IP client needs to be compiled from source.
On my Airport Extreme I enabled port-forwarding so that i can route services to the PI.
WiFi
If you want the PI to connect to your wireless network, just buy yourself a mini wifi USB adapter. It’s pretty easy to get the PI up and running with this on your local wifi, just enable the network device in /etc/network/interfaces, mine looks like this:
# /etc/network/interfaces auto wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa.config auto eth0 iface eth0 inet dhcp
and add the wifi connection settings to /etc/wpa.config:
# /etc/wpa.config
network={
ssid="YOUR_SSID"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="YOUR_PASSWORD"
}
Raspberry PI with cream and sugar!

