Skip to content

theodi/chef-odi-science-tiger

Repository files navigation

Dependency Status License Badges

#Science Tiger

Dashboards in the ODI office

We have dashboards. We have Raspberry Pis. We have four big-screen TVs. If only there was some way we could bring these things together...

We previously had a single Pi running just the Tech Team Dashboard on a single screen, but it had been lashed together with chewing-gum and string and was a terrible snowflake. If we want multiple displays, we need some ROBOTS!

##So what's in here?

This is a pretty simple Chef cookbook that will build and manage a set of Pis, each of which will boot into Midori (by default) in kiosk-mode, showing a single URL

##How to use it

It relies upon another git repo: by default, it will use our display-screen-content but it's unlikely you're going to want to put our dashboards on your screens. So create your repo thus:

  • a CSV file named for each of your nodes, containing
  • a single line, containing
  • a single field, viz. the URL you'd like to show on that node
  • except...

###The Huboard problem

Because REASONS, Huboard does not work at all on out-of-the-box Midori on Raspbian, and I expect other sites will be similarly afflicted. So you can add a second field to those CSVs to specify a browser - at the moment the only value supported there is chromium, and it's parsed with this horror-show, but it's working for us. YMMV

Whatever, set your new repo as the node['content_repo'] attribute

##Bootstrapping

So how to actually get this running on a Pi? I've spent so long firing up Rackspace Cloud nodes with Vagrant, I'd forgotten how to knife bootstrap...

###NOOBS

The recommended way to get Raspbian onto an SD card these days is with NOOBS, so download that and stick it on yer SD card, then boot the Pi with it (having first connected a screen, a mouse-and-keyboard, and a network cable). Choose Raspbian and let it do its thing, then at the red menu choose the thing that says something like 'Boot into GUI' (can't remember the exact words). It will reboot again, then it should log you in automatically. Open a terminal and run ifconfig, because you're going to need the IP address for the next step

###Knife

Presuming you have knife configured to talk to your Chef server, the next step should be as simple as:

PI_IP=whatever.you.got.above
NODENAME=naming-things-is-hard-01
knife bootstrap ${PI_IP} -x pi -P raspberry -d raspbian -N ${NODENAME} -r 'recipe[odi-science-tiger]' --sudo

Note that this doesn't work with Chef 12. In order specify a specific version of the knife command, you need something like

knife _11.18.6_ blah blah blah

(or however you do this kind of thing with chef-solo or chef-zero) and you should have a working node - you'll need to reboot it at the end of the run to get it to pick up all the changes, but from then it will be in the hands of the Chef robots

##Changing the content

You want to show a different URL? No problem. In whatever you're using for content_repo, change the CSV file for the node and push to master. On the next Chef run, the new CSV will be pulled onto the node and this change will trigger a restart of lightdm - we realise this is an extremely heavy-handed approach simply to get a browser to show a different URL, but our target URLs change infrequently so it's not a big deal for us. If, however, you know of a better way to do this, we're always open to PRs

There's a caveat here, however: this change to a single node's CSV will cause all of the nodes to think they have new content and they'll all restart X at the end of their next Chef run. Again, this isn't a big deal for us as we don't change our content too often, but if you can think of a better way...

##Tests

This cookbook has been built using Test Kitchen, to run the tests do:

git clone https://github.com/theodi/chef-odi-science-tiger
cd chef-odi-science-tiger
bundle
berks install
kitchen test

(You'll need Vagrant and VirtualBox installed, but I'm guessing that if you've read this far, you have those things)

##Next steps

This is very clearly not a finished thing. So:

###Rotating the URLs

We'd really like to be able to supply a list of URLs in those CSVs, and have the browser roll around them every minute or so. Anybody know an easy way to do this?

###Screen size

By default, we had some pretty thick black bars all around the edge of the displays (on our LG 42LN540V tellies). I've nailed in a fix for this here and here, but having to potentially set these for each different screen type feels like a hack. Anybody got any suggestions?

##WTF is a Science Tiger?

A Science Tiger is an animal that eats Information Radiators

##License

This code is open source under the MIT license. See the LICENSE.md file for full details