The tool cloud-init allows you to customize cloud (and bare metal) systems in a standardized way on first boot.
Documentation: https://cloudinit.readthedocs.io
Source Code: https://github.com/canonical/cloud-init