Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure /etc/machine-id is generate as early as possible in systemd #1178

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/static/kairos-overlay-files/collection.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages:
- name: "kairos-overlay-files"
category: "static"
version: "1.6.1"
version: "1.6.2"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -140,8 +147,15 @@ 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-setup.html
- 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
Expand Down
Loading