While re-running all of cloud-init without reboot isn’t a recommended approach, the following commands will allow you to accomplish this on a system.
The commands have been updated so to re-run you need to clean
out the existing config:
sudo cloud-init clean --logs
cloud-init typically runs multiple boot stages in order due to systemd service dependencies. If you want to repeat that process without a reboot you can run the following 4 commands:
-
Detect local datasource (cloud platform):
sudo cloud-init init --local
-
Detect any datasources which require network up and run “cloud_init_modules” defined in /etc/cloud/cloud.cfg:
sudo cloud-init init
-
Run all cloud_config_modules defined in /etc/cloud/cloud.cfg:
sudo cloud-init modules --mode=config
-
Run all cloud_final_modules defined in /etc/cloud/cloud.cfg:
sudo cloud-init modules --mode=final
Beware: things like ssh host keys maybe regenerated.