From a90d8338f07b30a46887f7c133baade63129a53a Mon Sep 17 00:00:00 2001 From: James Falcon Date: Fri, 29 Oct 2021 15:39:29 -0500 Subject: Allow libexec for hotplug (#1088) When we added the install hotplug module, we forgot to update the redhet/cloud-init.spec.in file and allow for execution on /usr/libexec. This PR adds that functionality. --- cloudinit/config/cc_install_hotplug.py | 10 +++++++--- cloudinit/sources/__init__.py | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/config/cc_install_hotplug.py b/cloudinit/config/cc_install_hotplug.py index d6b2a2df..da98c409 100644 --- a/cloudinit/config/cc_install_hotplug.py +++ b/cloudinit/config/cc_install_hotplug.py @@ -85,11 +85,11 @@ __doc__ = get_schema_doc(schema) HOTPLUG_UDEV_PATH = "/etc/udev/rules.d/10-cloud-init-hook-hotplug.rules" -HOTPLUG_UDEV_RULES = """\ +HOTPLUG_UDEV_RULES_TEMPLATE = """\ # Installed by cloud-init due to network hotplug userdata ACTION!="add|remove", GOTO="cloudinit_end" LABEL="cloudinit_hook" -SUBSYSTEM=="net", RUN+="/usr/lib/cloud-init/hook-hotplug" +SUBSYSTEM=="net", RUN+="{libexecdir}/hook-hotplug" LABEL="cloudinit_end" """ @@ -129,8 +129,12 @@ def handle(_name, cfg, cloud, log, _args): log.debug("Skipping hotplug install, udevadm not found") return + # This may need to turn into a distro property at some point + libexecdir = "/usr/libexec/cloud-init" + if not os.path.exists(libexecdir): + libexecdir = "/usr/lib/cloud-init" util.write_file( filename=HOTPLUG_UDEV_PATH, - content=HOTPLUG_UDEV_RULES, + content=HOTPLUG_UDEV_RULES_TEMPLATE.format(libexecdir=libexecdir), ) subp.subp(["udevadm", "control", "--reload-rules"]) diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index d61d280d..f2f2343c 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -196,6 +196,7 @@ class DataSource(CloudInitPickleMixin, metaclass=abc.ABCMeta): EventType.BOOT_NEW_INSTANCE, EventType.BOOT, EventType.BOOT_LEGACY, + EventType.HOTPLUG, }} default_update_events = {EventScope.NETWORK: { EventType.BOOT_NEW_INSTANCE, -- cgit v1.2.3