From 2048713452394e25171742f95414f08374c719ba Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 21 Sep 2023 16:35:00 -0500 Subject: [PATCH] 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. --- install-packages.service | 17 +++++++++++++++++ install-packages.sh | 8 ++++++++ packages.yaml | 16 ++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 install-packages.service create mode 100644 install-packages.sh create mode 100644 packages.yaml diff --git a/install-packages.service b/install-packages.service new file mode 100644 index 0000000..b42324a --- /dev/null +++ b/install-packages.service @@ -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 diff --git a/install-packages.sh b/install-packages.sh new file mode 100644 index 0000000..d5a9c55 --- /dev/null +++ b/install-packages.sh @@ -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 diff --git a/packages.yaml b/packages.yaml new file mode 100644 index 0000000..801f6d0 --- /dev/null +++ b/packages.yaml @@ -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