概要
Amazon Linux2.xでsystemdモジュールとserviceモジュールでサービスの起動時自動開始を設定しても、有効にならない現象に遭遇したので、その対処法を残したいと思います
easy missでした(2018.6.6追加)
systemdのnameにサービスのフルネームを記述しなければならないが、
.service
を含めない名前で記述していた
# ***** NG case *****
- name: Enable my service
systemd:
name: myservice
enabled: yes
# ***** OK case *****
- name: Enable my service
systemd:
name: myservice.service
enabled: yes
対処法
systemdを使わずにserviceモジュールに use: service を追加します
service.yml
- name: Enable my service
service:
name: myservice
enabled: yes
use: service
systemdのnameにサービスのフルネームを記述
systemd.yml
# ***** OK case *****
- name: Enable my service
systemd:
name: myservice.service
enabled: yes
確認方法
> systemctl list-unit-files