Skip to content

yvoderatskyi/raspiland

Repository files navigation

Raspiland

This project contains configurations for my Raspberry Pi (RPi)

Pre-requisites

Your machine

  • [X] Arch based OS (for example, Manjaro) with yay -Sy rpi-imager wireless_tools yank packages installed
  • [X] Python 3.7+ and poetry installed

Raspberry

  • [X] Internet connectivity: Ethernet or Wi-Fi
  • [X] SSH access enabled

Preparing for RPi OS for installation

Plug-in the SD card

Flash Ubuntu to the SD card

Select Operating System, SD Card and click on WRITE button. Wait for completion of the installation and verification. ./images/pi-imager.png

Configure Wi-Fi and SSH

echo ''
echo 'Please select your WI-Fi interface and network for RPi to connect to...'
SSID=$(ip link | grep -Po "(?<=^\d:\W).*?(?=:)" | yank | xargs -I % sh -c 'sudo iwlist % scan' | grep -Po "(?<=ESSID:\").*(?=\")" | sort | yank -l) || exit -1
[ -n $SSID ] || exit -1

echo ''
echo "Please, enter the password to connect to ${SSID}"
echo -n 'Password:'
read -s PASSWORD
echo "RPi will connect to ${SSID} network using password ${PASSWORD}."

echo ''
echo 'Please, select where system boot partition is mounted...'
MNT_DIR=$(sudo mount | yank)
[ -n $MTN_DIR ] || exit -1
echo "System boot parition is mounted to ${MNT_DIR}"

echo ''
echo "Creating empty file at ${MNT_DIR}/ssh"
[ -f ${MNT_DIR}/ssh ] || sudo tee -a ${MNT_DIR}/ssh < "" || echo exit -1

echo ''
echo ''
echo "Setting Wi-Fi configuration to ${MNT_DIR}/network-config"
sudo tee -a ${MNT_DIR}/network-config <<EOF
wifis:
  wlan0:
    dhcp4: true
    access-points:
      "${SSID}":
        password: "${PASSWORD}"
EOF

Let’s get started

Check SSH connection

poetry run ansible raspberry -i hosts.ini -m ping
➜  poetry run ansible raspberry -i hosts.ini -m ping
192.168.1.112 | SUCCESS => {
"ansible_facts": {
  "discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}

Provision the machine

poetry run ansible-playbook -i hosts.ini site.yaml
PLAY [raspberry] *******************************************************************************************

TASK [Gathering Facts] *************************************************************************************
ok: [192.168.1.112]

TASK [Update all packages to the latest version] ***********************************************************
ok: [192.168.1.112]

TASK [Install additional packages] *************************************************************************
ok: [192.168.1.112]

TASK [Alter user 'ubuntu' to allow access to 'docker'] *****************************************************
ok: [192.168.1.112]

TASK [Rebooting] *******************************************************************************************
changed: [192.168.1.112]

PLAY RECAP *************************************************************************************************
192.168.1.112              : ok=5    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Links

What’s next

Todo file with ideas can be found here

About

Raspberry Pi and all the things. Make RPi, Not War!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published