← Back to team overview

cloud-init team mailing list archive

Question on where x-shellscripts should go

 

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