Cloud-init script does not run (Vultr)


this is from the Rancher OS manual:

If the file starts with #!<interpreter> (e.g., #!/bin/sh), cloud-init will simply execute that file. You can place any configuration commands in the file as scripts.

However I am not able to make this working. If I run the script from running Rancher OS, it works correctly. Is it possible to debug the cloud-init process somehow? The problem is that if it fails, I cannot login to the system because of missing SSH keys, so it is very troublesome to debug.

Script example here:

This script has been tested on Vultr to launch and install Rancher OS instance. If I replace it by regular cloud config yml file, this file is processed correctly. Problem is with running the script.