There are some practical reasons motivating this exercise; however, the main reason is just for fun... Why not?
- 5 (or any other number) Raspberry Pi 3 Model B+
- A 32 GB micro SD card for each Raspberry Pi (I used a SanDisk ultra class 10, manufacturer number: SDSQUAR-032G-GN6TA)
- An ethernet switch (I used this 8-port 100 Mbps Renkforce Network Switch )
- A USB power supply with enough wattage (I used this ANKER 60W 10-Port)
- Micro-USB and ethernet cables
- A Raspberry Pi cluster case
The SD cards must be flashed (e.g. with raspbian),
ssh enabled (by creating an empty file called "ssh" in the boot partition: touch /mount-point/boot/ssh
), and the cluster turned on (of course) before starting with the configuration. Ansible was used to automate the configuration; in this way, the configuration can be done simultaneously on all devices.
-
nmap
or similar can be used to discover the devices IP addresses (in this example within the network 172.16.0.0/24). The IP addresses can be listed in an Ansible inventory.cfg.sudo nmap -sn 172.16.0.0-255 |grep rasp -i -B 2
-
The ansible playbooks are located in the
ansible
folder, and support the following tasks:-
Creating a new user (e.g.
macondo
), deploying an ssh public key, and, finally, deleting the old userpi
:ansible-playbook playbooks/create_user.yml -i inventory.cfg --user pi --ask-pass -e user_name=macondo -e ssh_key=FULL_PATH_TO_ID_RSA_PUB ansible-playbook playbooks/remove_user.yml -i inventory.cfg --user macondo --ask-become-pass -e user_name=pi
-
[Optional] Devices hostnames can be changed. This playbook has to be applied to each individual device, for instance:
ansible-playbook playbooks/change_hostname.yml -i "172.16.0.178," --user macondo --ask-become-pass -e hostname=remedios
My cluster nodes are called: ursula, amaranta, rebeca, pilar and remedios.
-
ansible-playbook playbooks/shutdown.yml -i inventory.cfg --user macondo --ask-become-pass
ansible-playbook playbooks/reboot.yml -i inventory.cfg --user macondo --ask-become-pass
For instance:
ansible all -m ping -i inventory.cfg -u macondo
Ansible is cool. Most of the steps described previously scale well, baptizing individual nodes is just a matter of personal taste.