openEuler 24.03安装saltstack-3006.9后使用salt-ssh命令报错

安装saltstack报错,不能使用报错如下:

[root@web-db shell]# 
[root@web-db shell]# systemctl status salt-master
● salt-master.service - The Salt Master Server
     Loaded: loaded (/usr/lib/systemd/system/salt-master.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2024-10-28 11:07:02 CST; 9min ago
       Docs: man:salt-master(1)
             file:///usr/share/doc/salt/html/contents.html
             https://docs.saltproject.io/en/latest/contents.html
   Main PID: 797242 (/opt/saltstack/)
      Tasks: 31 (limit: 205243)
     Memory: 268.3M
     CGroup: /system.slice/salt-master.service
             ├─ 797242 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master MainProcess"
             ├─ 797508 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master PubServerChannel._publish_daemon"
             ├─ 797514 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master EventPublisher"
             ├─ 797522 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master Maintenance"
             ├─ 797523 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master ReqServer ReqServer_ProcessManager"
             ├─ 797524 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master ReqServer MWorkerQueue"
             ├─ 797525 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master ReqServer MWorker-0"
             ├─ 797526 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master FileServerUpdate"
             ├─ 797527 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master ReqServer MWorker-1"
             ├─ 797528 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master ReqServer MWorker-2"
             ├─ 797535 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master ReqServer MWorker-3"
             └─ 797536 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master ReqServer MWorker-4"

Oct 28 11:07:02 web-db systemd[1]: Starting The Salt Master Server...
Oct 28 11:07:02 web-db systemd[1]: Started The Salt Master Server.
[root@web-db shell]# systemctl status salt-minion
● salt-minion.service - The Salt Minion
     Loaded: loaded (/usr/lib/systemd/system/salt-minion.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2024-10-28 11:07:03 CST; 9min ago
       Docs: man:salt-minion(1)
             file:///usr/share/doc/salt/html/contents.html
             https://docs.saltproject.io/en/latest/contents.html
   Main PID: 797284 (python3.10)
      Tasks: 7 (limit: 205243)
     Memory: 63.8M
     CGroup: /system.slice/salt-minion.service
             ├─ 797284 /opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion
             └─ 797382 "/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion MultiMinionProcessManager MinionProcessManager"

Oct 28 11:07:03 web-db systemd[1]: Starting The Salt Minion...
Oct 28 11:07:03 web-db systemd[1]: Started The Salt Minion.
[root@web-db shell]# salt-ssh -i "web-01" test.ping
Traceback (most recent call last):
  File "/usr/local/bin/salt-ssh", line 5, in <module>
    from salt.scripts import salt_ssh
ModuleNotFoundError: No module named 'salt'

解决办法
查看python是否安装到这个目录下了

/opt/saltstack/salt/bin/python3.10

找打salt的命令

[root@test-server ~]# which salt
/usr/bin/salt
[root@test-server ~]# which salt-ssh
/usr/bin/salt-ssh

这两个是运行python脚本内容的,打开脚本将第一行注释的行改成绝对路径的python

哪个salt命令使用报错都需要改一下

#!/opt/saltstack/salt/bin/python3.10
"true" ''''
"exec" "$(dirname "$(readlink -f "$0")")/bin/python3.10" "$0" "$@"
'''
# -*- coding: utf-8 -*-
import re
import sys
from salt.scripts import salt_main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(salt_main())

再次测试salt命令就可以正常使用了

[root@test-server ~]# salt-ssh -i "web-01" test.ping
web-01:
    True

粉丝福利
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/MRzhangshuang/article/details/143302897