From f5d93e34fa9bfce9c2bad2675940bafbcf757ebe Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Fri, 13 Dec 2024 10:22:52 +0200 Subject: [PATCH 1/3] Make sure /etc/machine-id is generate as early as possible in systemd Fixes https://github.com/kairos-io/kairos/issues/3038 Deprecates https://github.com/mudler/yip/pull/193 Signed-off-by: Dimitris Karakasilis --- .../files/system/oem/00_rootfs.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml b/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml index 6bce583a..54f61124 100644 --- a/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml +++ b/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml @@ -140,8 +140,18 @@ stages: name: "Restore /etc/machine-id for systemd systems" commands: - cat /usr/local/etc/machine-id > /etc/machine-id + # If we didn't restore it already, ensure /etc/machine-id is generated + - if: '[ -e "/sbin/systemctl" ] || [ -e "/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ]' + name: "Ensure /etc/machine-id for systemd systems" + commands: + # https://www.freedesktop.org/software/systemd/man/latest/systemd-machine-id-commit.service.html + # https://www.freedesktop.org/software/systemd/man/latest/systemd-machine-id-setup.html + # Mask the commit service to avoid systemd messing with machine-id. + - ln -s /dev/null /etc/systemd/system/systemd-machine-id-commit.service + - systemd-machine-id-setup + - if: '[ ! -f "/run/cos/recovery_mode" ] && [ -f "/sbin/openrc" ]' - name: "Restore /etc/machine-id for openrc systems" + name: "Ensure /etc/machine-id for openrc systems" commands: - dbus-uuidgen --ensure # This makes sure that the machine-id exists and its valid - cat /var/lib/dbus/machine-id > /etc/machine-id From 3401d75a905ca10f735a7614a186f843f23f92e7 Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Fri, 13 Dec 2024 10:42:56 +0200 Subject: [PATCH 2/3] Mask in rootfs (earlier) as per the PR comment https://github.com/kairos-io/packages/pull/1178#discussion_r1883552090 Signed-off-by: Dimitris Karakasilis --- .../files/system/oem/00_rootfs.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml b/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml index 54f61124..30adad81 100644 --- a/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml +++ b/packages/static/kairos-overlay-files/files/system/oem/00_rootfs.yaml @@ -106,6 +106,13 @@ stages: /var/run/cilium /var/snap PERSISTENT_STATE_BIND: "true" + - if: '[ -e "/sbin/systemctl" ] || [ -e "/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ]' + # Mask the commit service to avoid systemd messing with machine-id. + # https://www.freedesktop.org/software/systemd/man/latest/systemd-machine-id-commit.service.html + name: "Mask the commit service to avoid systemd messing with machine-id" + systemctl: + mask: + - systemd-machine-id-commit.service rootfs.after: - if: '[ -r /run/cos/custom-layout.env ] && [ ! -f "/run/cos/recovery_mode" ] && [ ! -f /run/cos/live_mode ]' name: "add custom bind and ephemeral mounts to /run/cos/cos-layout.env" @@ -144,10 +151,7 @@ stages: - if: '[ -e "/sbin/systemctl" ] || [ -e "/bin/systemctl" ] || [ -e "/usr/sbin/systemctl" ] || [ -e "/usr/bin/systemctl" ]' name: "Ensure /etc/machine-id for systemd systems" commands: - # https://www.freedesktop.org/software/systemd/man/latest/systemd-machine-id-commit.service.html # https://www.freedesktop.org/software/systemd/man/latest/systemd-machine-id-setup.html - # Mask the commit service to avoid systemd messing with machine-id. - - ln -s /dev/null /etc/systemd/system/systemd-machine-id-commit.service - systemd-machine-id-setup - if: '[ ! -f "/run/cos/recovery_mode" ] && [ -f "/sbin/openrc" ]' From cd667f8100ae5c16ea961e0ec55039958a94100b Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Fri, 13 Dec 2024 10:55:06 +0200 Subject: [PATCH 3/3] Bump version Signed-off-by: Dimitris Karakasilis --- packages/static/kairos-overlay-files/collection.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/static/kairos-overlay-files/collection.yaml b/packages/static/kairos-overlay-files/collection.yaml index 68d98a47..082eefdc 100644 --- a/packages/static/kairos-overlay-files/collection.yaml +++ b/packages/static/kairos-overlay-files/collection.yaml @@ -1,4 +1,4 @@ packages: - name: "kairos-overlay-files" category: "static" - version: "1.6.1" + version: "1.6.2"