From 9ad5baefea1b7cd13b0951de7941467f26586287 Mon Sep 17 00:00:00 2001 From: Stephen Lowrie Date: Wed, 21 Apr 2021 00:45:00 -0500 Subject: [PATCH] dracut: add ignition-kargs stage Adds a new kargs stage, as well as a binary implementation that prompts the user to contact their distribution to implement a kargs helper binary. --- dracut/30ignition/ignition-disks.service | 2 +- .../30ignition/ignition-fetch-offline.service | 2 +- dracut/30ignition/ignition-fetch.service | 2 +- dracut/30ignition/ignition-files.service | 2 +- dracut/30ignition/ignition-kargs-helper.sh | 8 +++++++ dracut/30ignition/ignition-kargs.service | 22 +++++++++++++++++++ dracut/30ignition/ignition-mount.service | 2 +- dracut/30ignition/ignition-setup-user.service | 2 +- dracut/30ignition/module-setup.sh | 4 ++++ 9 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 dracut/30ignition/ignition-kargs-helper.sh create mode 100644 dracut/30ignition/ignition-kargs.service diff --git a/dracut/30ignition/ignition-disks.service b/dracut/30ignition/ignition-disks.service index c046d3c366..66fa88383a 100644 --- a/dracut/30ignition/ignition-disks.service +++ b/dracut/30ignition/ignition-disks.service @@ -5,7 +5,7 @@ ConditionPathExists=/etc/initrd-release DefaultDependencies=false Before=ignition-complete.target -# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] [-> kargs] -> disks -> mount -> files. After=ignition-fetch.service Before=ignition-mount.service diff --git a/dracut/30ignition/ignition-fetch-offline.service b/dracut/30ignition/ignition-fetch-offline.service index d75d3911a2..0a18e0deff 100644 --- a/dracut/30ignition/ignition-fetch-offline.service +++ b/dracut/30ignition/ignition-fetch-offline.service @@ -11,7 +11,7 @@ DefaultDependencies=false Before=ignition-complete.target After=basic.target -# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] [-> kargs] -> disks -> mount -> files. # We run after the setup stage has run because it may copy in new/different # ignition configs for us to consume. After=ignition-setup-base.service diff --git a/dracut/30ignition/ignition-fetch.service b/dracut/30ignition/ignition-fetch.service index c4b3e36347..d629273d86 100644 --- a/dracut/30ignition/ignition-fetch.service +++ b/dracut/30ignition/ignition-fetch.service @@ -9,7 +9,7 @@ ConditionPathExists=/run/ignition/neednet # Don't run if the `fetch-offline` stage successfully fetched a config ConditionPathExists=!/run/ignition.json -# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] [-> kargs] -> disks -> mount -> files. # We run after the setup stage has run because it may copy in new/different # ignition configs for us to consume. After=ignition-fetch-offline.service diff --git a/dracut/30ignition/ignition-files.service b/dracut/30ignition/ignition-files.service index b1601f2f51..90bda675ab 100644 --- a/dracut/30ignition/ignition-files.service +++ b/dracut/30ignition/ignition-files.service @@ -8,7 +8,7 @@ Before=ignition-complete.target OnFailure=emergency.target OnFailureJobMode=isolate -# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] [-> kargs] -> disks -> mount -> files. After=ignition-mount.service # Run before initrd-parse-etc so that we can drop files it then picks up. diff --git a/dracut/30ignition/ignition-kargs-helper.sh b/dracut/30ignition/ignition-kargs-helper.sh new file mode 100644 index 0000000000..564122f429 --- /dev/null +++ b/dracut/30ignition/ignition-kargs-helper.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euxo pipefail + +# Send out a warning message to contact the distribution and exit. +# Distributions implementing Ignition kargs can override this binary +# with the actual implementation. +echo "Ignition kernelArguments is not supported by this Linux distribution.\nAsk your distribution to implement ignition-kargs-helper." +exit 1 diff --git a/dracut/30ignition/ignition-kargs.service b/dracut/30ignition/ignition-kargs.service new file mode 100644 index 0000000000..75cbb39a10 --- /dev/null +++ b/dracut/30ignition/ignition-kargs.service @@ -0,0 +1,22 @@ +[Unit] +Description=Ignition (kargs) +Documentation=https://github.com/coreos/ignition +ConditionPathExists=/etc/initrd-release +DefaultDependencies=false +Before=ignition-complete.target + +# Stage order: setup -> fetch-offline [-> fetch] [-> kargs] -> disks -> mount -> files. +After=ignition-fetch.service +Before=ignition-disks.service + +OnFailure=emergency.target +OnFailureJobMode=isolate + +[Service] +Type=oneshot +RemainAfterExit=yes +EnvironmentFile=/run/ignition.env +ExecStart=/usr/bin/ignition --root=/sysroot --platform=${PLATFORM_ID} --stage=kargs +# MountFlags=slave is so the umount of /boot is guaranteed to happen. +# /boot will only be mounted for the lifetime of the unit. +MountFlags=slave diff --git a/dracut/30ignition/ignition-mount.service b/dracut/30ignition/ignition-mount.service index a733d1a4fe..b3af2fa8f3 100644 --- a/dracut/30ignition/ignition-mount.service +++ b/dracut/30ignition/ignition-mount.service @@ -5,7 +5,7 @@ ConditionPathExists=/etc/initrd-release DefaultDependencies=false Before=ignition-complete.target -# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] [-> kargs] -> disks -> mount -> files. # We need to make sure the partitions and filesystems are set up before # mounting. This is also guaranteed through After=initrd-root-fs.target but # just to be explicit. diff --git a/dracut/30ignition/ignition-setup-user.service b/dracut/30ignition/ignition-setup-user.service index b3ad98b315..aa0524c23a 100644 --- a/dracut/30ignition/ignition-setup-user.service +++ b/dracut/30ignition/ignition-setup-user.service @@ -8,7 +8,7 @@ Before=ignition-complete.target OnFailure=emergency.target OnFailureJobMode=isolate -# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] [-> kargs] -> disks -> mount -> files. Before=ignition-fetch-offline.service # We want to make sure we're not racing with multipath taking ownership of the diff --git a/dracut/30ignition/module-setup.sh b/dracut/30ignition/module-setup.sh index 73c23054fe..e51112f817 100755 --- a/dracut/30ignition/module-setup.sh +++ b/dracut/30ignition/module-setup.sh @@ -59,6 +59,9 @@ install() { inst_script "$moddir/ignition-setup-user.sh" \ "/usr/sbin/ignition-setup-user" + inst_script "$moddir/ignition-kargs-helper.sh" \ + "/usr/sbin/ignition-kargs-helper" + # Distro packaging is expected to install the ignition binary into the # module directory. inst_simple "$moddir/ignition" \ @@ -83,6 +86,7 @@ install() { install_ignition_unit ignition-setup-user.service install_ignition_unit ignition-fetch.service install_ignition_unit ignition-fetch-offline.service + install_ignition_unit ignition-kargs.service install_ignition_unit ignition-disks.service install_ignition_unit ignition-mount.service install_ignition_unit ignition-files.service