combustion/README
Ignaz Forster 651ee08f24 Accepting request 835192 from home:favogt:combustion
- Overhaul configuration fetching:
  * Add udev rules to wait for either ignition, combustion or
    fw_cfg drives
  * Allow combustion.firstboot in addition to ignition.firstboot
  M combustion
  A combustion-prepare.service
  M combustion.service
  M module-setup.sh
- Bump version to 0.2

OBS-URL: https://build.opensuse.org/request/show/835192
OBS-URL: https://build.opensuse.org/package/show/devel:kubic:ignition/combustion?expand=0&rev=7
2020-09-18 07:12:39 +00:00

80 lines
3.3 KiB
Plaintext

Combustion - configure MicroOS on the first boot
================================================
Combustion is a minimal module for dracut, which runs a user provided script on
the first boot of a system.
You can use this to create additional files, install packages, set up devices
or even re-partition the hard disk. The configuration can be provided as a
shell script, loaded from an external storage media and is run during boot in a
new system snapshot. On success, the system will directly boot into that new
snapshot, so that no reboot is needed.
How to use it
-------------
The configuration files are copied from a filesystem with the LABEL
"combustion", but to be compatible and co-installable with ignition
(https://github.com/coreos/ignition), the LABEL "ignition" is used as fallback.
It expects a directory "combustion" at the root level of the filesystem and
a file "script" inside, which is executed inside a transactional-update shell.
If a QEMU fw_cfg blob with the name "opt/org.opensuse.combustion/script" is
found, it is preferred and the content of that is used as script.
Example parameter for QEMU:
-fw_cfg name=opt/org.opensuse.combustion/script,file=/var/combustion-script
Example for formatting a USB drive and adding a config, which installs the
"vim-small" package and creates a /root/welcome file:
```
mkfs.ext4 /dev/sdX
e2label /dev/sdX ignition
mount /dev/sdX /mnt
mkdir -p /mnt/combustion/
cat >/mnt/combustion/script <<EOF
#!/bin/sh
# combustion: network
systemctl enable sshd.service
zypper --non-interactive install vim-small
cp welcome /root/welcome
EOF
echo "Hello User!" >/mnt/combustion/welcome
umount /mnt
```
The "# combustion: network" comment indicates that network needs to be
configured before running the script.
You can do everything necessary for initial system configuration from this
script, including addition of ssh keys, adding users, changing passwords
or even doing partitioning changes.
How it works
------------
The ignition-dracut-grub2 package created a flag file which tells GRUB 2 that
it's the first boot of the system and so GRUB adds "ignition.firstboot" to the
kernel commandline.
If this option is found on the kernel cmdline, combustion.service's
ConditionKernelCommandLine is fulfilled and it'll be required by initrd.target.
This pulls in combustion-prepare.service, which runs after the config drive or
QEMU fw_cfg blob appears (see combustion.rules for details). It is read and if
the "network" flag comment is present, enables networking for later.
After /sysroot is mounted and network is up (if enabled), combustion.service
runs, which tries to activate all mountpoints in the system's /etc/fstab and
then calls transactional-update in a chroot.
In this transactional-update session the script is started and the exit code
recorded. If the script failed, transactional-update rollback is called and
combustion.service marked as failed, which causes booting to fail. Note that a
missing config drive or script is not considered a fatal error and only results
in a warning.
/sysroot is unmounted and mounted again, so that the default subvolume gets
reevaluated and directly booted into.
The ignition-firstboot-complete service in the final system runs, which deletes
the flag file. This means that combustion is not run on subsequent boots.