Chapter 11. Using shell scripts with cloud-init
You can add list values or string values to bootcmd or runcmd in cloud-init. You can also provide a shell script within userdata to execute custom commands during VM initialization.
- If you use a string value, the entire string runs as a shell script.
-
If you use a list value for
bootcmdorruncmd, each list item runs in turn usingexecve. -
If you want to use
cloud-initto run a shell script, provide a shell script (complete with shebang#!) instead of providingcloud-initwith a.yamlfile.
Refer to Run commands on first boot for examples of how to put shell scripts in bootcmd and runcmd.