diff --git a/dracut/30ignition/ignition-disks.service b/dracut/30ignition/ignition-disks.service index 241f5d8..f55e84f 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 -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] -> 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 new file mode 100644 index 0000000..e752971 --- /dev/null +++ b/dracut/30ignition/ignition-fetch-offline.service @@ -0,0 +1,29 @@ +[Unit] +Description=Ignition (fetch-offline) +Documentation=https://github.com/coreos/ignition +ConditionPathExists=/etc/initrd-release +DefaultDependencies=false +Before=ignition-complete.target +After=basic.target + +# Stage order: setup -> fetch-offline [-> fetch] -> 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 +After=ignition-setup-user.service +Before=ignition-fetch.service + +# See hack below, as well as coreos-copy-firstboot-network.service. +After=dracut-cmdline.service +Before=dracut-initqueue.service + +[Service] +Type=oneshot +RemainAfterExit=yes +EnvironmentFile=/run/ignition.env +ExecStart=/usr/bin/ignition --root=/sysroot --platform=${PLATFORM_ID} --stage=fetch-offline +# Hack: we need to rerun the NM cmdline hook because we run after +# dracut-cmdline.service because we need udev. We should be able to move away +# from this once we run NM as a systemd unit. See also: +# https://github.com/coreos/fedora-coreos-config/pull/346#discussion_r409843428 +ExecStart=/usr/bin/sh -c ". /usr/lib/dracut-lib.sh && . /usr/lib/dracut/hooks/cmdline/99-nm-config.sh" diff --git a/dracut/30ignition/ignition-fetch.service b/dracut/30ignition/ignition-fetch.service index 269a8b4..78b3378 100644 --- a/dracut/30ignition/ignition-fetch.service +++ b/dracut/30ignition/ignition-fetch.service @@ -5,16 +5,15 @@ ConditionPathExists=/etc/initrd-release DefaultDependencies=false Before=ignition-complete.target After=basic.target +ConditionPathExists=/etc/cmdline.d/40-ignition-neednet.conf -# Stage order: setup -> fetch -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] -> 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 -After=ignition-setup-user.service +After=ignition-fetch-offline.service Before=ignition-disks.service - -# Network may be used to fetch userdata content. +# If we run, it's that we definitely need network, so make sure we run after After=network.target [Service] diff --git a/dracut/30ignition/ignition-files.service b/dracut/30ignition/ignition-files.service index 704cc26..27841ff 100644 --- a/dracut/30ignition/ignition-files.service +++ b/dracut/30ignition/ignition-files.service @@ -5,7 +5,7 @@ ConditionPathExists=/etc/initrd-release DefaultDependencies=false Before=ignition-complete.target -# Stage order: setup -> fetch -> disks -> mount -> files. +# Stage order: setup -> fetch-offline [-> fetch] -> 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-mount.service b/dracut/30ignition/ignition-mount.service index b32c93f..e6512f7 100644 --- a/dracut/30ignition/ignition-mount.service +++ b/dracut/30ignition/ignition-mount.service @@ -5,6 +5,13 @@ ConditionPathExists=/etc/initrd-release DefaultDependencies=false Before=ignition-complete.target +# Stage order: setup -> fetch-offline [-> fetch] -> 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. +After=ignition-disks.service +Before=ignition-files.service + # Make sure ExecStop= runs before we switch root Before=initrd-switch-root.target @@ -19,13 +26,6 @@ After=initrd-root-fs.target # Make sure root filesystem is remounted read-write if needed After=ignition-remount-sysroot.service -# Stage order: setup -> fetch -> 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. -After=ignition-disks.service -Before=ignition-files.service - [Service] Type=oneshot RemainAfterExit=yes diff --git a/dracut/30ignition/ignition-setup-base.service b/dracut/30ignition/ignition-setup-base.service index d58c204..7699551 100644 --- a/dracut/30ignition/ignition-setup-base.service +++ b/dracut/30ignition/ignition-setup-base.service @@ -5,8 +5,8 @@ ConditionPathExists=/etc/initrd-release DefaultDependencies=false Before=ignition-complete.target -# Stage order: setup -> fetch -> disks -> mount -> files. -Before=ignition-fetch.service +# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +Before=ignition-fetch-offline.service [Service] Type=oneshot diff --git a/dracut/30ignition/ignition-setup-user.service b/dracut/30ignition/ignition-setup-user.service index b387f2b..2f4cc79 100644 --- a/dracut/30ignition/ignition-setup-user.service +++ b/dracut/30ignition/ignition-setup-user.service @@ -5,8 +5,8 @@ ConditionPathExists=/etc/initrd-release DefaultDependencies=false Before=ignition-complete.target -# Stage order: setup -> fetch -> disks -> mount -> files. -Before=ignition-fetch.service +# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files. +Before=ignition-fetch-offline.service # We want to make sure we're not racing with multipath taking ownership of the # boot device. diff --git a/dracut/30ignition/module-setup.sh b/dracut/30ignition/module-setup.sh index 1e4dd89..943e7c0 100755 --- a/dracut/30ignition/module-setup.sh +++ b/dracut/30ignition/module-setup.sh @@ -71,6 +71,7 @@ install() { install_ignition_unit ignition-setup-base.service install_ignition_unit ignition-setup-user.service install_ignition_unit ignition-fetch.service + install_ignition_unit ignition-fetch-offline.service install_ignition_unit ignition-disks.service install_ignition_unit ignition-mount.service install_ignition_unit ignition-files.service