A place to hold Ansible roles that have proved useful in more than one project
Generally for projects involving Raspberry Pi. Use this entire repository as a template for building out an Ansible-based project.
- Install Ansible on your computer
- Install the latest Raspbian lite image onto a micro-SD card
- Create a file called
ssh
on the/boot
partition of the SD card. The contents don't matter, it's just to enable the SSH server. E.g. on Ubuntutouch /media/myusername/boot/ssh
- Boot the Raspberry Pi with the micro-SD card, while plugged into a network via Ethernet
- Find out the IP address of the Raspberry Pi
- Use nmap (eg:
nmap -p 22 192.168.0.* --open
), router or monitor to find IP address of Pi once booted.
- Copy your SSH credentials onto the Pi
ssh-copy-id pi@<ip-address-of-the-pi>
- Edit the
hosts
file so ansible knows which computer to configure. Change the IP address in it to match the one you just found out. - Check you can run commands on the Pi using Ansible
ansible controlled-pi -i hosts -a "hostname" -u pi
- Edit custom-install-steps.yml to set the roles that you want for this Pi, add any installation steps, etc. that you need to provision the Pi for the task you need it to do.
- Update the Pi, using the playbook you customised in the last step, e.g.
ansible-playbook custom-install-steps.yml -i hosts
These are some of the roles (sets of Ansible commands to fulfil a particular function) that you might want to use:
- base-nodered Bare minimum Node RED installation, which runs automatically when the Pi is started up
- renamed-pi Change the hostname of the Pi
- nm-wireless Use NetworkManager to configure networking, and pre-define Wifi network details. Copy
roles/nm-wireless/vars/main-example.yml
toroles/nm-wireless/vars/main.yml
and edit it to include the details of the Wifi networks to be set up