使用 salt-tack 停止 systemd 服务
Stopping systemd service with salt-tack
我正在使用 salt-stack 来管理我的生产机器。
minions 运行 Raspbian 和我和我已经配置了 systemd 服务。服务配置文件位于 /lib/systemd/system/my_service.service
当我运行以下命令时:
sudo salt my_minion service.stop my_service
返回以下错误:
ERROR: Unable to run command ['/etc/init.d/my_service', 'stop'] with the context {'with_communicate': True, 'shell': False, 'env': {'LANG': 'en_GB.UTF-8', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'LC_ALL': 'C'}, 'stdout': -1, 'close_fds': True, 'stdin': None, 'stderr': -2, 'cwd': '/root'}, reason: [Errno 2] No such file or directory
我知道 salt 尝试使用 sysvinit 而不是 systemd。
有没有办法让 salt 使用 systemd?
编辑:
尝试添加
providers:
service: systemd
到 /etc/salt/minion 正如 Eric 所建议的。仍然出现相同的错误
编辑 2
问题已通过使用 Erics 的建议 + 将 salt-minion 从 2015.8.3 升级到 2015.8.8 得到解决
这几乎可以肯定是因为较新的 Raspbian 是基于 Debian 8 的,而 Salt 的 systemd 执行模块没有正确检测到较新的 Raspbian 需要 systemd。 OP 能否使用 sudo salt my_minion grains.items
的输出回复此消息?请编辑您认为具有个人身份信息的任何 grains,我主要对处理 OS 名称和版本的 grains 感兴趣。
编辑: 还有一件事。请确认 /run/systemd/system
存在于 Raspbian 框中。我认为这里发生的是两个模块都声称是提供 service
模块的模块。
https://github.com/saltstack/salt/pull/32421 应该可以解决这个问题,但是您可以通过将以下内容添加到 Raspbian minions 上的 /etc/salt/minion
来立即解决这个问题(无需等待新的 Salt 版本):
providers:
service: systemd
我正在使用 salt-stack 来管理我的生产机器。 minions 运行 Raspbian 和我和我已经配置了 systemd 服务。服务配置文件位于 /lib/systemd/system/my_service.service
当我运行以下命令时:
sudo salt my_minion service.stop my_service
返回以下错误:
ERROR: Unable to run command ['/etc/init.d/my_service', 'stop'] with the context {'with_communicate': True, 'shell': False, 'env': {'LANG': 'en_GB.UTF-8', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'LC_ALL': 'C'}, 'stdout': -1, 'close_fds': True, 'stdin': None, 'stderr': -2, 'cwd': '/root'}, reason: [Errno 2] No such file or directory
我知道 salt 尝试使用 sysvinit 而不是 systemd。
有没有办法让 salt 使用 systemd?
编辑:
尝试添加
providers:
service: systemd
到 /etc/salt/minion 正如 Eric 所建议的。仍然出现相同的错误
编辑 2
问题已通过使用 Erics 的建议 + 将 salt-minion 从 2015.8.3 升级到 2015.8.8 得到解决
这几乎可以肯定是因为较新的 Raspbian 是基于 Debian 8 的,而 Salt 的 systemd 执行模块没有正确检测到较新的 Raspbian 需要 systemd。 OP 能否使用 sudo salt my_minion grains.items
的输出回复此消息?请编辑您认为具有个人身份信息的任何 grains,我主要对处理 OS 名称和版本的 grains 感兴趣。
编辑: 还有一件事。请确认 /run/systemd/system
存在于 Raspbian 框中。我认为这里发生的是两个模块都声称是提供 service
模块的模块。
https://github.com/saltstack/salt/pull/32421 应该可以解决这个问题,但是您可以通过将以下内容添加到 Raspbian minions 上的 /etc/salt/minion
来立即解决这个问题(无需等待新的 Salt 版本):
providers:
service: systemd