dnf-automatic で夜間に更新を自動化していますが、アップデート後に毎回不具合がおこるため、後から手作業で対応しているアプリケーション(パッケージ)がありました。
DNF の post-transaction-actions プラグイン を使って、アップデートの後処理を自動化したので記録しておきます。
環境
- OS:AlmaLinux release 9.6 (Sage Margay)
- DNF:バージョン 4.14.0
- ホスティング: ConoHa VPS(メモリ 2GB)
アップデートで発生する不具合
OpenLiteSpeed(1.8.4-6)
アップデート後にサービスを再起動しないと、ウェブサイトが 503 エラーで見られない状態になる事態が連続して発生しました。

Rspamd(3.13)
設定ファイル置き場(/etc/rspamd/local.d/)の所有者が root に変更され、Web GUI(_rspamd ユーザー)から設定の保存ができない。

DNF プラグインの設定
プラグインをインストールする前に、導入されている DNF 関連パッケージの一覧を確認しておきます。
dnf -v repolist
(out) Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, kpatch, needs-restarting, notify-packagekit, playground, repoclosure, repodiff, repograph, repomanage, reposync, system-upgrade
(out) DNF version: 4.14.0インストール
post-transaction-actions プラグインが入っていなかったので、インストールを実行します。パッケージ名は python3-dnf-plugin-post-transaction-actions でした。
dnf install python3-dnf-plugin-post-transaction-actions
(out) Dependencies resolved.
(out) ================================================================================================
(out) Package Arch Version Repository Size
(out) ================================================================================================
(out) Installing:
(out) python3-dnf-plugin-post-transaction-actions noarch 4.3.0-20.el9 baseos 17 k
(out)
(out) Transaction Summary
(out) ================================================================================================
(out) Install 1 Package
(out)
(out) Total download size: 17 k
(out) Installed size: 14 k
(out) Is this ok [y/N]: y
(out) Downloading Packages:
(out) python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch 1.4 MB/s | 17 kB 00:00
(out) ------------------------------------------------------------------------------------------------
(out) Total 27 kB/s | 17 kB 00:00
(out) Running transaction check
(out) Transaction check succeeded.
(out) Running transaction test
(out) Transaction test succeeded.
(out) Running transaction
(out) Preparing : 1/1
(out) Installing : python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch 1/1
(out) Running scriptlet: python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch 1/1
(out) Verifying : python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch 1/1
(out)
(out) Installed:
(out) python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch
(out)
(out) Complete!アクションファイルの作成
post-transaction-actions プラグインがインストールされると、/etc/dnf/plugins/post-transaction-actions.d/ ディレクトリが作られます。
このディレクトリ内にアクションファイル(.action)を配置する事で設定を行います。
コロン(:)で区切って、パッケージ名:トランザクションの状態:コマンド の順に記述します。
トランザクションの状態には 3 種類あり、in・out・any のいずれかになります。
- in:パッケージの追加(install・update・reinstall など)
- out:パッケージの削除(remove など)
OpenLiteSpeed
openlitespeed が in(upgrade)されたら、サービスを再起動します。
openlitespeed:in:/usr/bin/systemctl restart lshttpd.serviceRspamd
rspamd が in(upgrade)されたら、設定用ディレクトリの所有権を変更します。
rspamd:in:/usr/bin/chown _rspamd:_rspamd /etc/rspamd/local.d/


コメント