I'm trying to start a process at boot on a Ubuntu 14 LTS AMI (
cloud-init's per-boot script facility and configure that process with EC2 userdata. The process has sensible defaults but I'm attempting to allow these defaults to be overridden by using EC2 userdata to write some bits to
However, when I drop the custom per-boot script on disk (
/var/lib/cloud/scripts/per-boot/run-process.sh) it executes as expected but the EC2 userdata step does not run. If I launch a version of this AMI without the per-boot script the EC2 userdata step runs as expected. It seems as if the per-boot script is clobbering the EC2 userdata step.
The EC2 userdata script I am using looks like this:
#!/bin/bash echo "CLUSTER=foo" >> /etc/default/foo
/etc/cloud/cloud.cfg I would expect this step to run before the
cloud_final_modules: - rightscale_userdata - scripts-vendor - scripts-per-once - scripts-per-boot - scripts-per-instance ...
Further, manually running the running the
cloud-final step as well as the userdata step individually works fine
sudo cloud-init modules --mode=final sudo cloud-init single -n rightscale_userdata
Towards the end of my investigation I noticed that when I add the
#cloud-boothook directive at the top of the userdata script everything works as expected:
#cloud-boothook #!/bin/bash echo "CLUSTER=foo" >> /etc/default/foo
I realize that there are a dozen other ways to accomplish this but I'm really looking to understand why I'm seeing this behavior. So, what am I missing here?