From 7eb8bf74d419a6845566d75d02b59c68789fc859 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 3 Oct 2024 15:34:11 +0200 Subject: [PATCH] Add foreman_ygg_migration package This package should get pulled in when yggdrasil >=0.4.z is installed. When installed, it checks whether yggdrasild.service is enabled. If not, it does nothing. If enabled, this package tweaks yggdrasil's config file to account for the newly needed config options and migrates service overrides from the old service to the new worker. Additionally, it disables the yggdrasild service and enables yggdrasil.service. Our worker is left to be activated through dbus. --- comps/comps-foreman-client-el8.xml | 1 + comps/comps-foreman-client-el9.xml | 1 + comps/comps-foreman-client-rhel7.xml | 1 + package_manifest.yaml | 1 + .../foreman_ygg_migration.spec | 32 +++++++++++++++++++ 5 files changed, 36 insertions(+) create mode 100644 packages/client/foreman_ygg_migration/foreman_ygg_migration.spec diff --git a/comps/comps-foreman-client-el8.xml b/comps/comps-foreman-client-el8.xml index 17b0b6e9615..298e07803eb 100644 --- a/comps/comps-foreman-client-el8.xml +++ b/comps/comps-foreman-client-el8.xml @@ -11,6 +11,7 @@ true foreman-client-release + foreman_ygg_migration foreman_ygg_worker katello-host-tools katello-host-tools-tracer diff --git a/comps/comps-foreman-client-el9.xml b/comps/comps-foreman-client-el9.xml index 17b0b6e9615..298e07803eb 100644 --- a/comps/comps-foreman-client-el9.xml +++ b/comps/comps-foreman-client-el9.xml @@ -11,6 +11,7 @@ true foreman-client-release + foreman_ygg_migration foreman_ygg_worker katello-host-tools katello-host-tools-tracer diff --git a/comps/comps-foreman-client-rhel7.xml b/comps/comps-foreman-client-rhel7.xml index c456dd26af1..fe2476a7345 100644 --- a/comps/comps-foreman-client-rhel7.xml +++ b/comps/comps-foreman-client-rhel7.xml @@ -11,6 +11,7 @@ true foreman-client-release + foreman_ygg_migration foreman_ygg_worker katello-host-tools katello-host-tools-tracer diff --git a/package_manifest.yaml b/package_manifest.yaml index 7600dcdc529..db6d2c10a8f 100644 --- a/package_manifest.yaml +++ b/package_manifest.yaml @@ -532,6 +532,7 @@ foreman_client_packages: children: yggdrasil_client_packages: {} hosts: + foreman_ygg_migration: {} foreman_ygg_worker: {} katello-host-tools: {} katello-pull-transport-migrate: {} diff --git a/packages/client/foreman_ygg_migration/foreman_ygg_migration.spec b/packages/client/foreman_ygg_migration/foreman_ygg_migration.spec new file mode 100644 index 00000000000..2e5c7552703 --- /dev/null +++ b/packages/client/foreman_ygg_migration/foreman_ygg_migration.spec @@ -0,0 +1,32 @@ +Name: foreman_ygg_migration +Version: 0.0.1 +Summary: A helper package to ease transition from yggdrasil 0.2.z to 0.4.z +Release: 1%{?dist} +License: MIT + +Supplements: yggdrasil >= 0.4.0 +Requires: yggdrasil >= 0.4.0 + +%description +A helper package to ease transition from yggdrasil 0.2.z to 0.4.z + +%post +if systemctl is-enabled yggdrasild >/dev/null 2>/dev/null; then + grep -Pq '^server' /etc/yggdrasil/config.toml || sed -i 's/broker.*=/server =/' /etc/yggdrasil/config.toml + grep -Pq '^prefix' /etc/yggdrasil/config.toml || echo 'prefix = "yggdrasil"' >>/etc/yggdrasil/config.toml + grep -Pq '^data-host' /etc/yggdrasil/config.toml || echo 'data-host = ""' >>/etc/yggdrasil/config.toml + + if grep -q FOREMAN_YGG_WORKER_WORKDIR /etc/systemd/system/yggdrasild.service.d/* 2>/dev/null; then + mkdir -p /etc/systemd/system/com.redhat.Yggdrasil1.Worker1.foreman.service.d/ + cp -r /etc/systemd/system/yggdrasild.service.d/* /etc/systemd/system/com.redhat.Yggdrasil1.Worker1.foreman.service.d/ + fi + + systemctl disable --now yggdrasild + systemctl enable --now yggdrasil +fi + +%files + +%changelog +* Thu Oct 03 2024 Adam Ruzicka - 0.0.1-1 +- Initial packaging