I've been trying unsuccessfully to get cloud-init working on DigitalOcean for a little while now and finally had some time to re-tackle the problem. I think I've found an issue with the way that the cloud-init config files are ordered.
Basically, I'm building a custom VyOS image with the vyos-vm-image repo and using the following option for datasources:
`cloud_init_ds=DigitalOcean,NoCloud,ConfigDrive,None`
What was happening was that the cloud-init user-data was getting written to disk, but not applied using the vyos_config_commands module.
After many hours of digging, I realized that is because if you look [here on the vyos cloud-init repo](https://github.com/vyos/vyos-cloud-init/tree/current/config/cloud.cfg.d) that the VyOS config file is named `10_vyos.cfg` but that the readme for that folder explicitly states
```
# All files with the '.cfg' extension in this directory will be read by
# cloud-init. They are read in lexical order. Later files overwrite values in
# earlier files.
```
And when the image is generated with those options, the DigitalOcean provider config file starts with 90 meaning it will be processed after the VyOS one (not sure if this also affects other providers, I still need to test that as the cloud-init docs say that the DigitalOcean provider is now deprecated in favor of ConfigDrive).
Because of this, anything set by the DigitalOcean provider takes over the settings of the VyOS one meaning the VyOS specific modules never actually run after the user-data and other info is grabbed by the DigitalOcean provider.
I've fixed this in my custom image by adding this task to the end of the install-cloud-init role in the vyos-vm-images repo:
```
- name: Fix number of vyos file
become: true
command: cp {{ vyos_install_root }}/etc/cloud/cloud.cfg.d/10_vyos.cfg {{ vyos_install_root }}/etc/cloud/cloud.cfg.d/99_vyos.cfg
```
It's a hacky solution, but does work and the commands are executed as expected at boot. I do see some errors related to IP addresses and DHCP, but it seems to not actually be an issue so probably something that needs polished.