Scripts in /var/lib/cloud/scripts/vendor are never run
Bug report
I was looking at using vendor scripts as another place to drop in scripts to run. It doesn't look like these actually ever get run? I also see that cc_vendor_scripts use the current instance path. But this is a symlink to a path with the launched instance ID so it doesn't seem possible to include a script in there. Is there a way to use vendor scripts then in AWS with EC2?
I was trying to provide a set of scripts to run on boot that wouldn't collide with other user scripts.
Steps to reproduce the problem
Put a script in /var/lib/cloud/scripts/vendor
Environment details
- Cloud-init version:
- Operating System Distribution: Ubuntu 24.04
- Cloud provider, platform or installer type: AWS EC2
Thank you @tejom for filing this bug and making cloud-init better. The support for dropping files into /var/lib/cloud/vendor looks like it was dropped in 2014 per 42f2cffadabfefb0469ade2f1f1c3ce5edabc9fa.
Given that custom image creators (vendors) have the ability to place scripts anywhere on the filesystem directly in custom images, we'd suggest installing vendor-related scripts into one for the following directories depending on how frequently you'd prefer those scripts are run:
- /var/lib/cloud/scripts/per-boot: Run any executable scripts in this directory every single boot
- /var/lib/cloud/scripts/per-instance: run every time a new
instance-idis provided by the datasource - /var/lib/cloud/scripts/per-once: just run once and never run again
I was trying to provide a set of scripts to run on boot that wouldn't collide with other user scripts.
The way we can avoid collisions with other scripts is by not-naming the vendor scripts.
If users are looking to provide scripts during boot, they can do something like:
- provide simple cloud-config user-data containing write_files
#cloud-config
write_files:
- path: /var/lib/cloud/scripts/per-once/once.sh
content: IyEvYmluL2Jhc2gKZWNobyBDSEFEIE9OQ0UK
encoding: b64
permissions: '0755'
- create a mime message using cloud-init devel which can allow one to specify per-boot, per-instance or per-always scripts.
Do these options provide you with the necessary knobs you are looking for?
Oh that's so old.
I guess with conflicts I was also worried about order. I thought maybe I could vendor to make sure some of our scripts are always ran and in the order expected without any of our users messing with it. Ill see if the work arounds work then.
Is /var/lib/cloud/scripts/vendor an Ubuntu packaging thing then?