In a previous post I discussed using Ansible to install Docker and Docker Compose on Debian. Since then I’ve taken this and made some updates as I’ve gone and modified for use on a Raspberry Pi 4 instead of just testing on a Linode instance.
As fun (complicated?) as it was manually doing all the steps to install Docker, there is a nice first party install script you can curl and run instead. It was not usable on the RPi 4 previously which is why I had not originally used it but it has since been updated and works perfectly on Raspbian.
Another upside of this change is it means you don’t have to manually check and set the architecture and release when you set up the repos. All that is handled by the script.
Docker Compose Installation
Docker Compose is now installed using Pip rather than curling the binary and dropping it on the box. The main downside is this take makes longer to run, especially since the pip install has native code that needs to be compiled and its happening on the RPi itself. The main upside is… well I guess I’d just rather use a package manager in this case? Perhaps the rationale for this change is not as strong as the other one.
Also note that Docker Compose seems to have problems with Python 2’s backported libraries on Debian. There are currently two that gave me problems on Raspbian:
You can either (1) uninstall them with pip and then reinstall them with apt or (2) install and use Python 3 instead.
Note that I also made the choice to install into the system Python rather than a virtual environment for simplicity.
Running the Playbook
Final change is the playbook now uses a ssh connection rather than running locally on the RPi so it must now be provided an inventory when run.
The updated playbook
Here is the updated playbook: