packages: Add framework for installing packages

Some machines may need to install multiple packages for separate use
cases.  Requiring each use case to define a systemd unit that runs
`rpm-ostree install` directly would be cumbersome and also quite slow,
as each one would have to run in turn.  Instead, now there is a single
*install-packages.service* which installs all of the packages listed in
files in `/etc/ignition/packages.d`.  On first boot, all files in that
directory are read and all the packages they list will be installed in a
single `rpm-ostree install` invocation.
master
Dustin 2023-09-21 16:35:00 -05:00
parent 22c085b35d
commit 2048713452
3 changed files with 41 additions and 0 deletions

17
install-packages.service Normal file
View File

@ -0,0 +1,17 @@
# vim: set ft=systemd :
[Unit]
Description=Install collectd
After=network-online.target
Wants=network-online.target
Before=zincati.service
ConditionPathExists=/etc/ignition/packages.d
ConditionPathExists=/etc/ignition/packages.installed
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh /etc/ignition/install-packages.sh
ExecStartPost=/bin/touch /etc/ignition/packages.installed
[Install]
WantedBy=multi-user.target

8
install-packages.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
if [ ! -d /etc/ignition/packages.d ]; then
exit 0
fi
cat /etc/ignition/packages.d/* | xargs rpm-ostree install --apply-live -y

16
packages.yaml Normal file
View File

@ -0,0 +1,16 @@
variant: fcos
version: 1.4.0
storage:
directories:
- path: /etc/ignition/packages.d
mode: 0755
files:
- path: /etc/ignition/install-packages.sh
mode: 0755
contents:
local: install-packages.sh
- path: /etc/systemd/system/install-packages.service
mode: 0644
contents:
local: install-packages.service