i'm having trouble in setting up a full headless install for Ubuntu Server Focal (ARM) on a Raspberry pi 4 using cloud init config. The whole purpose of doing this is to simplify the SD card swap in case of failure. I'm trying to use cloud-init config files to apply static config for lan/wlan, create new user, add ssh authorized keys for the new user, install docker etc. However, whatever i do it seems the Wifi settings are not applied before the first reboot.
Step1: burn the image on SD Card. Step2: rewrite SD card system-boot/network_config and system-boot/user-data with config files
network-config
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: false
optional: true
addresses: [192.168.100.8/24]
gateway4: 192.168.100.2
nameservers:
addresses: [192.168.100.2, 8.8.8.8]
wifis:
wlan0:
optional: true
access-points:
"AP-NAME":
password: "AP-Password"
dhcp4: false
addresses: [192.168.100.13/24]
gateway4: 192.168.100.2
nameservers:
#search: [mydomain, otherdomain]
addresses: [192.168.100.2, 8.8.8.8]
user-data
chpasswd:
expire: true
list:
- ubuntu:ubuntu
# Enable password authentication with the SSH daemon
ssh_pwauth: true
groups:
- myuser
- docker
users:
- default
- name: myuser
gecos: My Name
primary_group: myuser
groups: sudo
shell: /bin/bash
ssh_authorized_keys:
- ssh-rsa AAAA....
lock_passwd: false
passwd: $6$rounds=4096$7uRxBCbz9$SPdYdqd...
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- git
runcmd:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
- add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- apt-get update -y
- apt-get install -y docker-ce docker-ce-cli containerd.io
- systemctl start docker
- systemctl enable docker
## TODO: add git deployment and configure folders
power_state:
mode: reboot
During the first boot cloud-init always applies the fallback network config.
I also tried to apply the headless config for wifi as described here.
Created wpa_supplicant.conf and copied it to SD system-boot folder.
trl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=RO
network={
ssid="AP-NAME"
psk="AP-Password"
}
Also created an empty ssh file and copied it to system-boot
The run commands always fail since during the first boot cloud-init applies the fallback network config. After reboot, lan/wlan settings are applied, the user is created, ssh authorized keys added. However i still need to ssh into the PI and install install the remaining packages: docker etc, and i wanted to avoid this. Am i doing something wrong?
raspi-config is a powerful tool when changing settings for the Raspberry Pi. Unfortunately, it is only available on Raspberry Pi OS (formerly called Raspbian), and can only be installed on that. It is available on Ubuntu MATE 20.04 LTS Focal Fossa, but it stopped appearing on Groovy Gorilla or Hirsute Hippo.
Once this is done, start the Imager and open the “CHOOSE OS” menu. Scroll down the menu click “Other general-purpose OS”. You will then be able to see a list of Ubuntu downloads to choose from. Select the “Ubuntu 20.10 Desktop (Raspberry Pi 4)” option.
The Raspberry Pi 4 has a 64-bit processor and can run 64-bit images. Because it can run 64-bit images, you can choose either Kali Linux RaspberryPi 2, 3, 4 and 400 (img. xz) or Kali Linux RaspberryPi 2 (v1. 2), 3, 4 and 400 (64-Bit) (img.
I'm not sure if you ever found a workaround, but I'll share some information I found when researching options.
network-config
with WiFi:Note: During the first boot, your Raspberry Pi will try to connect to this network. It will fail the first time around. Simply reboot
sudo reboot
and it will work.
There's an interesting workaround & approach in this repo.
netplan
and systemd-networkd
.Personally, I've gone a different route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With