Score:1

Ubuntu Server on Pi: Does cloud-init re-run every boot?

ar flag

I installed the official Ubuntu Server 22.04 image on a Raspberry Pi 4. I also configured my wireless network in the network-config file on the SD card.

That file gets transformed by cloud-init into /etc/netplan/50-cloud-init.yaml with this preamble inserted:

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}

I'm skeptical of this claim – if I modify the original /boot/firmware/network-config file it doesn't cause 50-cloud-init.yaml to get regenerated.

On the other hand, cloud-init.service and cloud-config.service are both still enabled and seem to run at boot.

Score:2
th flag

It depends. Cloud-init does run every boot, but for most boots, it will mostly be a no-op.

On first boot, cloud-init obtains meta data, user data, and network config from a cloud. All of this info is cached, so on subsequent boots, it doesn't need or try to re-obtain this information from the cloud. Some clouds override this behavior to obtain this data every single boot, but for raspberry pi, this should only happen on first boot. It then runs through a number of modules to process any provided cloud-config. Any module that has a Module frequency of always will run every boot. If one runs cloud-init clean or the cloud provides the instance with a new instance id, cloud-init will (mostly) re-run things as if it were first boot.

For your use case, you're correct. It would be more correct for the comment to say "Changes are not guaranteed to persist across an instance reboot." However, if you run cloud-init clean, then you should see that file re-generated.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.