
systemd serviceを使用して気が付いたのですが、systemd serviceファイルをオーバーライドする方法としてdrop-inという仕組みがあります。
/etc/systemd/system/unit.d/override.conf
のような形でファイルを用意する必要があるのですが、その中で[Service]セクションにあったEnvironmentFile
という変数についてです。
というのも、とあるパッケージをインストールするとデフォルトで用意されるsystemd serviceファイルの中にEnvironmentFileを指定する箇所があるのですが、これが/path/to/file
と記述されていて、適宜修正する形になっていたのです。
これをある環境に一括でばらまこうとしたときに、drop-inの形でファイルを用意して、EnvironmentFile
を用意して、設定自体を上書こうかと思ったのですが、実行してみると以下のような結果に。
Nov 29 00:02:33 dns05 systemd[1]: irqbalance.service: Failed to load environment files: No such file or directory
Nov 29 00:02:33 dns05 systemd[1]: irqbalance.service: Failed to run 'start' task: No such file or directory
Nov 29 00:02:33 dns05 systemd[1]: irqbalance.service: Failed with result 'resources'.
Nov 29 00:02:33 dns05 systemd[1]: Failed to start irqbalance daemon.
Failed to load environment files: No such file or directory
となり、該当するEnvironmentFileの読み込みに失敗した、というメッセージが出力されます。
なんでかなーと思って一応調査してみました。

How to set environment variable in systemd service?
I have an Arch Linux system with systemd and I've created my own service. The configuration service at /etc/systemd/system/myservice.service looks like this: De...

How to specify an Environment systemd directive containing =?
I want to specify an Environment systemd directive containing =, e.g. Environment=CATALINA_OPTS=-Dappserver.home=/var/lib/archiva/apache-tomcat-current -Dappser...

How do I override or configure systemd services?
Many sysv init scripts used a corresponding file in /etc/default to allow the administrator to configure it. Upstart jobs can be modified using .override files....
が、EnvironmentFileのオーバーライドに関する記述は見つけられませんでした。
今のところ自分なりには以下のように対応するしかなさそうな感じです。
この辺りについて、もっとスマートな方法があるようでしたらご教示ください。