Re-running all of cloud-init without system reboo isn't a recommended approach because some parts of cloud-init are run at systemd generator timeframe to detect new datasource types. That said, the following commands will allow you to accomplish this without reboot on a system.
cloud-init supports a clean
subcommand to remove all semaphore files and allow cloud-init to re-run all config modules again. Beware that this will mean SSH host-keys are regenerated and .ssh config files re-written so it could impact your ability to get back into the VM.
To clean all semaphores so cloud-init modules will all re-run on next boot:
sudo cloud-init clean --logs
cloud-init typically runs multiple boot stages in sequence 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) and obtain user-data:
sudo cloud-init init --local
- Detect any datasources and user-data 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