cloud-init icon indicating copy to clipboard operation
cloud-init copied to clipboard

[bug] hardcoded configuration directories

Open holmanb opened this issue 1 year ago • 0 comments

Bug report

ds-identify provides an environment variable PATH_ETC_CLOUD by which its configuration files may be located under different directories for distro-specific configurations. This allows some distros to configure the directory used in init scripts rather than carrying downstream patches.

Cloud-init's Python codebase is not so flexible. It attempts to be DRY, by storing config locations in a common file. This keeps required downstream patches simple, however several parts of the codebase ignore this pattern and hardcode path locations:

> rg '"/etc/cloud' cloudinit/
cloudinit/settings.py
15:CLOUD_CONFIG = "/etc/cloud/cloud.cfg"
17:CLEAN_RUNPARTS_DIR = "/etc/cloud/clean.d"
62:            "templates_dir": "/etc/cloud/templates/",

cloudinit/helpers.py
318:            "templates_dir", "/etc/cloud/templates/"

cloudinit/cmd/devel/logs.py
44:    ApportFile("/etc/cloud/cloud.cfg.d/99-installer.cfg", "InstallerCloudCfg"),

cloudinit/cmd/status.py
24:CLOUDINIT_DISABLED_FILE = "/etc/cloud/cloud-init.disabled"

cloudinit/config/cc_apt_configure.py
380:    flist = glob.glob(subp.target_path(path="/etc/cloud/cloud.cfg.d/*dpkg*"))

cloudinit/sources/DataSourceMAAS.py
405:                fpath = "/etc/cloud/cloud.cfg.d/" + fname + ".cfg"

Resolution

Cloud-init should follow ds-identify's pattern and support the PATH_ETC_CLOUD environment variable, as well as clean up hardcoded configuration directory paths.

holmanb avatar Feb 29 '24 17:02 holmanb