← Back to team overview

cloud-init team mailing list archive

Re: Question on where x-shellscripts should go


I think I've found at least a partial answer to this ... not sure, but I
suspect the /v/l/c/scripts/per-* folders are used by the cc_script_per_*
modules, and the /v/l/c/iinstance/scripts folder is used by the
scripts-user module.

Actually, from looking at the code, I'm 99.9% sure this is what's
happening. And that there won't be any conflict, they're just independent

On Fri, Aug 28, 2020 at 3:30 PM Bean Taxi <beantaxi@xxxxxxxxx> wrote:

> Hello all,
> From the handler/shell_script.py code, and from experience & thanks to
> this list, MIME encoded shellscripts get copied to
> /var/lib/cloud/instance/scripts.
>     def __init__(self, paths, **_kwargs):
>         handlers.Handler.__init__(self, PER_ALWAYS)
>         self.script_dir = paths.get_ipath_cur('scripts')
>         if 'script_path' in _kwargs:
>             self.script_dir = paths.get_ipath_cur(_kwargs['script_path'])
> After spending quite a bit of time trying to find where the proper per-*
> subfolder gets created, I finally realized that it doesn't:
> /var/lib/cloud/instance/scripts is a flat folder. That makes me wonder
> how cloud-init knows how often to run those scripts, but maybe that's what
> the scripts-user module is for, particularly the 'Always' tactic.
> I'm not sure what the relationship is between /var/lib/cloud/instance/scripts
> and /var/lib/cloud/scripts/per-*. I have used write_files to write
> scripts to the per-* folders directly from a cloud_config.yaml, as per a
> suggestion on #cloud-init, and that indeed works. But I'm not sure how the
> two script folders might conflict with each other.
> My ultimate goal is to write a very simple custom part handler, for a type
> I'm calling x-shellscript-per-boot, which saves to
> /var/lib/cloud/scripts/per-boot. And I'd like to do this so that I can
> deploy a per-instance script and a per-boot script in the same MIME config.
> which ultimately is my requirement. And I'm a little concerned I'll be
> mixing methods.
> Thanks!
> Bean

Follow ups