手动执行后systemctl start example.service
,它会启动,但不会自动作为 ansible 的一部分,而具有相同配置的其他应用程序会启动。警告是什么The service is actually an init script but the system is managed by systemd
意思?其他启动的应用程序没有此警告。
安塞布尔脚本:
- name: Enable service
service: name=example enabled=yes
安塞布尔日志:
TASK [provision-app : Enable service] ***********************
Sunday 08 December 2019 17:25:42 +0000 (0:00:01.100) 0:00:28.007 *******
[WARNING]: The service (example) is actually an init script but
the system is managed by systemd
服务文件:
/run/systemd/generator.late/example.service
/run/systemd/generator.late/runlevel5.target.wants/example.service
/run/systemd/generator.late/runlevel4.target.wants/example.service
/run/systemd/generator.late/runlevel3.target.wants/example.service
/run/systemd/generator.late/runlevel2.target.wants/example.service
.服务文件:
# Automatically generated by systemd-sysv-generator
[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/rc.d/init.d/example
Description=SYSV: Application Suite
Before=runlevel2.target
Before=runlevel3.target
Before=runlevel4.target
Before=runlevel5.target
After=network-online.target
After=network.service
[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/rc.d/init.d/example start
系统控制状态:
Loaded: loaded (/etc/rc.d/init.d/example; bad; vendor preset: disabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
答案1
也许不是OP的真正答案,但由于谷歌把我带到这里来获取相同的错误消息,我将在这里发布我的发现。
当我的内核更新到 5.8(从 5.4)时,Ansible 模块service
或systemd
开始失败,并出现相同的警告The service (your_service_name) is actually an init script but the system is managed by systemd
和消息。Service is in unknown state
事实证明,您需要升级您的 systemd 版本以适应一些更改。就我在 Ubuntu 上的情况而言,systemd 245.4-4ubuntu3 无法工作,但 245.4-4ubuntu3.5 可以工作(来自 focus-updates)。
快速检查:
systemctl show sshd | grep ActiveState
Failed to parse bus message: Invalid argument
如果您得到无效参数输出,请更新。