Skip to content

Ansible playbooks for day 1 operations on a Raspberry Pi!

License

Notifications You must be signed in to change notification settings

RyanDevlin/Raspiansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspiansible

Ansible roles to fully configure a new Raspberry Pi.

Getting Started

Automated Setup

  1. Plug an SD card into your machine.
  2. Run the SD card configuration playbook
$ ansible-playbook sdconfig.yml

Manual Setup

  1. Download Raspbian OS here [lite version preferred]: https://www.raspberrypi.org/downloads/raspberry-pi-os/
  2. Plug an SD card into your machine and use lsblk to determine where it is mounted. Here we see our SD card is identified as the device /dev/sda.
kanye@kanyes-pc:~/Downloads$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    1  14.8G  0 disk 
├─sda1        8:1    1   3.1G  0 part /media/kanye/music
└─sda2        8:2    1   736K  0 part
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:1    0   529M  0 part 
├─nvme0n1p2 259:2    0    99M  0 part /boot/efi
├─nvme0n1p3 259:3    0    16M  0 part 
├─nvme0n1p4 259:4    0 911.4G  0 part 
└─nvme0n1p5 259:5    0  19.5G  0 part /
  1. Unmount any partitions on the SD card to ensure we can safely overwrite it.
kanye@kanyes-pc:~/Downloads$ umount /dev/sda1
  1. Use dd to copy the OS image to the SD card. This will delete everything on the SD card.
kanye@kanyes-pc:~/Downloads$ sudo dd if=~/Downloads/2020-05-27-raspios-buster-lite-armhf.img of=/dev/sda bs=4096
  1. When dd has completed, remount the SD card, or unplug it, then plug it back in.
  2. Run the following command to configure the Pi so it autoconnects to your network. Be sure to edit the text in '<>'. For a list of ISO country codes see here.
kanye@kanyes-pc:~/Downloads$ cat <<EOF >> wpa_supplicant.conf
> ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
> update_config=1
> country=<Insert 2 letter ISO 3166-1 country code here>
> 
> network={
>  ssid="<Name of your wireless LAN>"
>  psk="<Password for your wireless LAN>"
> }
> EOF
  1. Place the newly created wpa_supplicant file in the 'boot' directory on the SD card.
kanye@kanyes-pc:~/Downloads$ mv /media/kanye/boot/wpa_supplicant.conf
  1. Place a file named 'ssh' within the boot directory. This will trigger the Pi to enable SSH on bootup.
kanye@kanyes-pc:~/Downloads$ touch /media/kanye/boot/ssh
  1. Finally unmount the SD partitions, put the SD card in the Pi, and power it on.
kanye@kanyes-pc:~/Downloads$ umount /dev/sda1
kanye@kanyes-pc:~/Downloads$ umount /dev/sda2

About

Ansible playbooks for day 1 operations on a Raspberry Pi!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages