{"id":1340,"date":"2013-07-31T18:01:17","date_gmt":"2013-07-31T16:01:17","guid":{"rendered":"http:\/\/blog.gocept.com\/?p=1340"},"modified":"2013-07-31T18:01:17","modified_gmt":"2013-07-31T16:01:17","slug":"reproducable-automated-deployments-on-raspberrypi-with-batou","status":"publish","type":"post","link":"https:\/\/blog.gocept.com\/2013\/07\/31\/reproducable-automated-deployments-on-raspberrypi-with-batou\/","title":{"rendered":"Reproducable automated deployments on RaspberryPi with batou"},"content":{"rendered":"
For continuous integration during development, we use Jenkins to automatically run tests for all projects we maintain. Some time ago we wanted to increase visibility of the results, so we set up a Raspberry Pi<\/a> driving a few meters of LPD8806-based LED<\/a> strip on which we can address single LEDs to represent the status of individual or aggregated builds.<\/p>\n After an SD Card failure we were painfully remembered how hard it can be to set up a service where all parts were deployed manually. Fortunately we wrote at least some minimal documentation on how to set everything up, so after a few days we were presented with many broken builds. Of course nobody cared about the build status with all LEDs being dark. \ud83d\ude41<\/p>\n Today we wondered if we can use our deployment-tool batou<\/a> to make reproduceable deployments to a raspberry pi, and did some tests on a vanilla raspbian image (2013-07-26 “Wheezy”).<\/p>\n Of course, you can not deploy to it without some simple preparations. First thing is, batou needs to be able to log on the target host with a public ssh key, so we copied our public key to the raspi which has the address 192.168.0.5 in this example:<\/p>\n (If you don’t have the ssh-copy-id, you have to manually append your ssh public key to Batou does also have a few requirements which are needed to bootstrap the environment:<\/p>\n Note: We are currently working on batou 1.0 which most likely will no longer need any of these.<\/em><\/p>\n You can install all the requirements at once with the following command on your raspi:<\/p>\n Now you are ready to do your first batou deployment to a raspberry pi. For our experiments we created a small hello-world batou deployment, containing a test component which deploys a file \/tmp\/test which contains “foo” to a raspberry pi specified by an IP address.<\/p>\n To begin, clone the repository on your local machine:<\/p>\n Now, edit To create the nessecary scripts to do the deployment, run buildout to create a sandbox containing all dependencies of batou and the scripts you can use to deploy:<\/p>\n After some minutes, your batou deployment sandbox will be ready for use. You most likely modified To run the deployment, call batou-remote with the name of the environment (“pi”, which corresponds to Batou will now set up itself on the remote side and deploys all components specified in To learn more about batou, check http:\/\/batou.readthedocs.org.Automating deployments is a good idea…<\/h2>\n
Let’s automate!<\/h2>\n
Preparing your Raspberry Pi<\/h2>\n
\r\nlocal> ssh-copy-id pi@192.168.0.5\r\npi@192.168.0.5's password:\r\nType password of user pi, default: \"raspberry\"<\/pre>\n
\/home\/pi\/.ssh\/authorized_keys<\/code>, which you will need to create on a plain installation)<\/p>\n
Manually install minimal requirements<\/h2>\n
\n
\r\npi> sudo aptitude install mercurial python-virtualenv python-dev<\/pre>\n
Prepare batou<\/h2>\n
local> hg clone https:\/\/bitbucket.org\/gocept\/batou-on-raspberrypi\r\nlocal> cd batou-on-raspberrypi<\/pre>\n
environments\/pi.cfg<\/code> and set the IP-address of your Raspi.<\/p>\n
local> python bootstrap.py\r\n\u2026\r\nlocal> bin\/buildout<\/pre>\n
Deploy!<\/h2>\n
environments\/pi.cfg<\/code> so you need to check in that change first, because batou refuses to deploy a dirty working copy.<\/p>\n
\r\nlocal> hg ci -m 'change ip of my raspi'\r\n<\/pre>\n
environments\/pi.cfg<\/code>). Because the ssh user you use to connect with the target host differs from your local user, you have to specify it with
--ssh-user<\/code>.<\/p>\n
\r\nlocal> bin\/batou-remote pi --ssh-user=pi\r\n<\/pre>\n
pi.cfg<\/code>. To show it worked, check if the deployed file contains the correct content:<\/p>\n
pi> cat \/tmp\/test\r\nfoo\r\n<\/pre>\n
Further readings<\/h2>\n
\n<\/a>
\nIf you want deploy your real life mission critical python applications into a fully automated environment using batou, head over to the Flying Circus<\/a>.<\/p>\nTL;DR<\/h2>\n
\n
\n