Integrate a new system
Raspberry Pi
When integrating a new Pi, a few steps need to be performed before it can be
integrated with the rest of the Ansible config.
First of all, an SD card should be formatted with Debian Raspberry
Pi as the operating system. Before booting for the
first time, change the following in /boot/firmware/sysconf.txt
(you can do
this by simply having the SD card mounted on your computer):
- Set
hostname
to the desired name
- Set
root_authorized_key
to the contents of the current computer's public
SSH key
Now the SD card can be inserted into the Raspberry Pi. Connect the Pi to the
LAN using a wired connection and let it boot. After a little while, it should
show up on the local network with a DNS-assigned IP. You can discover what IP
it received in many ways; I usually just check the router's configuration
panel. Finally, decide what static IP the Pi should be assigned to from here on
out.
Now you can run the initial configuration of the Pi with the following command:
ansible-playbook -i [original ip], -e ansible_ssh_user=root -e static_ip=[static ip] first_run.yml
The first_run.yml
playbook installs Python 3 and sets up the base user and
SSH configuration so all other Ansible roles can work properly. Note that this
playbook will hang forever on the final step, "restart networking". This is due
to the Pi changing IPs without Ansible knowing. Once you reach this step, you
can simply Ctrl-C the playbook execution.
Now your Pi should be ready to be used with the rest of the configuration.