Skip to content

Commit

Permalink
dracut: add ignition-kargs stage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Stephen Lowrie committed Apr 28, 2021
1 parent 383893d commit 9ad5bae
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-disks.service
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-fetch-offline.service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-fetch.service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-files.service
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions dracut/30ignition/ignition-kargs-helper.sh
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions dracut/30ignition/ignition-kargs.service
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-mount.service
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-setup-user.service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions dracut/30ignition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -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
Expand Down

0 comments on commit 9ad5bae

Please sign in to comment.