Azure / azure-init

A minimal provisioning agent designed for Azure Linux VMs.
MIT License
12 stars 12 forks source link

Best usage practices: Starting early in boot #35

Open pothos opened 9 months ago

pothos commented 9 months ago

Current situation

The systemd unit provided looks like it would run in the final system.

Impact

The instance configuration can be racy because while the system is set up by the agent other services will already start and, e.g., an SSH provisioning helper or cloud-init would race with the agent.

Debatable whether this is desired behavior: The current usage also overwrites a static hostname because the unit is running late and because the unit runs at every boot and ignores a previously set static hostname.

Ideal future situation

Provide a systemd unit that runs in the initrd, and possibly a dracut module to pull it in. This is how Afterburn is used, too, e.g., when setting up the hostname. Similar is also how Ignition is used, which does the creation of user accounts from the initrd.

Then document how the unit should be installed in the initrd and that this is the recommended way compared to a unit on the final system.

**Implementation options

Additional information

pothos commented 6 months ago

I think it would make sense to follow what afterburn does: Have CLI arguments that define what action is done. This way one could do the hostname, network, and user setup in the initrd but the boot checkin in the final system based on CLI args. For distros that also makes it a bit more flexible when integrating.