I try to configure a Raspberry PI 3b+ using HypriotOS 1.9 with Cloud init. To do so, I put a user-data
file into the root of the boot volume. According to the docs, this should be picked up automatically and execute the changes described in the file (eg. change hostname).
However, none of these changes happens and looking at the log output of cloud-init does not seem to indicate that the file is even being picked up correctly.
I am using the hypriot flash utility to copy files to the target OS. when i mount the SD card and check if user-data is copied and valid yaml - then indeed it is.
Has somebody experienced something similar or have a good clue on what is happening?
More information is:
user-data (template, actual values get interpolated):
# vim: set ts=2 sw=2 filetype=yaml:
---
hostname: $TEMPLATE_HOSTNAME
manage_etc_hosts: true
users:
- name: r9s
gecos: "Raspbernetes User"
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
groups: users,docker,video,input
plain_text_passwd: r9spwd
lock_passwd: true
ssh_pwauth: false
locale: "de_DE.UTF-8"
timezone: "Europe/Berlin"
write_files:
- content: |
allow-hotplug: wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
path: /etc/network/interfaces.d/wlan0
- content: |
country=de
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="$TEMPLATE_SSID"
psk="$TEMPLATE_PSK"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
path: /etc/wpa_supplicant/wpa_supplicant.conf
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSkvewNpUkKQp/uXNEAMkqQyEjZeLQmcVje9XStvn92cNq3NO2Ij6S+pBtGcB4IYxYjjT8Nv5GxUDS51gZYg/F2Blr4jnOKXkpSyRZwRFiZ05dNaU6DRjK9ETujAdTYa7jmsrbZEejuG8YcVlfJkOvQeRxI+Y6pgAw+hl9ZwcQ8oHwcZbPFJgCbDgOUv6IssLNbKvLgt/vKHcd74oHVN9y+NtpLk4+mdWCzLv/STjshZVxP/Xz896irIBuKEnPhNO1qvTctTVJpEBvwGjA/RgFVjLpY8gSwLHlr5vTcLtKgyMZ7+xr6iKFlSPQovfugokJ5eBYG5Zn4oAy99KuVJbB matthias@rusty-nail
runcmd:
- 'systemctl restart avahi-daemon'
- 'ifup wlan0'
the answer was, that user-data files need to start with a line containing exactly this sequence:
#cloud-config
if not present, the file is ignored and skipped as if it were not there. This is actually documented in the cloud init docs. Nevertheless it's very hard to find when just scanning through the documentation.
the hypriot tutorials i found didn't mention it and the line was not present in the examples there.