- Ansible playbook to perform General OS configuration settings on a Raspberry Pi 3/4.
- Playbook not intented to run as a CI/CD pipeline. But can be integrated to a Github Workflow if needed.
- CI Testing for Ansible roles are configured with Github Actions.
- This work is done as part of a Hobby project on setting up an IoT Stack in a Home network.
- The playbooks are configured to use SSH Keys instead of username/password to connect to Raspberry Pi.
- Pre-requisites:
- Add the SSH public key
id_rsa.pub
to/home/pi/.ssh/authorized_keys
in Raspberry Pi. - Find IP addresses of Raspberry Pis in home network.
$ nmap -sn -p 22 <home_network_cidr> | grep pi $ nmap -sV -p 22 192.168.0.0/24 –open | grep pi
- Add the SSH public key
- ping:
- This role is used to test connectivity to Raspberry Pi.
- docker:
- Install Docker and Docker Compose in
Armv7
orArm64
architectures.
- Install Docker and Docker Compose in
- os-setup:
- Disable power saving mode
- Check WiFi: Detect WiFi connection loss and restart the network service.
- Generate an Ansible inventory file named
hosts.ini
using the template filehosts_example.ini
. Update the inventory group rpi with Raspberry Pi host information.$ mv hosts_example.ini hosts.ini $ cat hosts.ini [vagrant] localhost ansible_user=vagrant ansible_port=2222 [rpi] 192.168.10.100 ansible_user=pi ansible_port=22
- Run Ansible ping
$ ansible-playbook -i hosts.ini ansible_ping.yml -l rpi
- Run Ansible playbook to configure Raspberry Pi OS.
$ ansible-playbook -i hosts.ini playbook.yml -l rpi
- [Optional] Get System info of Servers Raspberry Pi OS.
$ ansible-playbook -i hosts.ini system_info.yml
- CI testing for docker role using Github Actions cannot be run directly. Because of Docker-in-Docker scenario.
- User can always run the Molecule testing locally to test and verify the role.
- Ansible Molecule Testing
- geerlingguy.ansible-role-docker_arm
- Installing Docker and Docker Compose on the Raspberry Pi in 5 Simple Steps
- Installing Docker on the Raspberry Pi
- dockerpi
- Does Your Raspberry Pi 3 Lose WiFi Connections After a While
- Rebooting the Raspberry Pi when it loses wireless connection
- Ansible Playbook for Get Hosts Information