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

[RFC] dracut: add an ignition-sysusers service #1153

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions dracut/30ignition/ignition-files.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Before=ignition-complete.target
OnFailure=emergency.target
OnFailureJobMode=isolate

# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
After=ignition-mount.service
# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> sysusers -> files.
After=ignition-sysusers.service

# Run before initrd-parse-etc so that we can drop files it then picks up.
Before=initrd-parse-etc.service
Expand Down
4 changes: 2 additions & 2 deletions dracut/30ignition/ignition-mount.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ 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] -> disks -> mount -> sysusers -> 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
Before=ignition-sysusers.service

# Make sure ExecStop= runs before we switch root
Before=initrd-switch-root.target
Expand Down
19 changes: 19 additions & 0 deletions dracut/30ignition/ignition-sysusers.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Ignition (sysusers)
Documentation=https://github.com/coreos/ignition
ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target

OnFailure=emergency.target
OnFailureJobMode=isolate

# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> sysusers -> files.
After=ignition-mount.service
Before=ignition-files.service

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/run/ignition.env
ExecStart=/usr/sbin/chroot /sysroot /bin/bash -c "mount proc /proc -t proc && /usr/bin/systemd-sysusers && umount /proc"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few doubts I got while going through this:

  • I think the on-disk results of this will need to be wired into existing selinux-relabeling signaling mechanisms, right?
  • should this logic be better placed in a script file or in Go as part of Ignition?
  • should sysusers and config-users handling be moved to a single dedicated Ignition stage?
  • naming bikeshedding?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of literally chrooting, we should lift https://github.com/openshift/os/blob/e808d5f364aae2a846793a0d7af7be8cc886871d/overlay.d/05rhcos/usr/lib/dracut/modules.d/40rhcos-fips/rhcos-fips.sh#L97-L120 out of there and into e.g. a sysroot-bwrap command we can just call.

1 change: 1 addition & 0 deletions dracut/30ignition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ install() {
install_ignition_unit ignition-fetch-offline.service
install_ignition_unit ignition-disks.service
install_ignition_unit ignition-mount.service
install_ignition_unit ignition-sysusers.service
install_ignition_unit ignition-files.service

# units only started when we have a boot disk
Expand Down