salt除了支持Master 和Minion方式以外,還支持SSH; SSH方式由於沒有minion主動鏈接master,因此須要維護 roster,提供master能夠操做的對象;roster的配置文件默認在:/etc/sat/rosternode
[root@linux-node1 ~]# cat /etc/salt/roster # Sample salt-ssh config file #web1: # host: 192.168.42.1 # The IP addr or DNS hostname # user: fred # Remote executions will be executed as user fred # passwd: foobarbaz # The password to use for login, if omitted, keys are used # sudo: True # Whether to sudo to root, not enabled by default #web2: # host: 192.168.42.2 linux-node1.oldboyedu.com: host: 192.168.74.20 port: 22 user: root linux-node2.oldboyedu.com: host: 192.168.74.32 port: 22 user: root # priv: /root/.ssh/id_rsa
若是在roster的配置文件中沒有寫入私鑰文件或者密碼,第一次操做的時候,須要寫入密碼python
[root@linux-node1 ~]# salt-ssh '*' test.ping -i
以後就能夠正常操做了linux
[root@linux-node1 ~]# salt-ssh '*' test.ping linux-node1.oldboyedu.com: True linux-node2.oldboyedu.com: True [root@linux-node1 ~]# salt-ssh '*' cmd.run 'uptime' linux-node1.oldboyedu.com: 16:08:30 up 12:09, 1 user, load average: 0.01, 0.03, 0.05 linux-node2.oldboyedu.com: 16:08:26 up 8:15, 1 user, load average: 0.19, 0.11, 0.07 [root@linux-node1 ~]# salt-ssh '*' -r 'uptime' linux-node1.oldboyedu.com: ---------- retcode: 0 stderr: stdout: 16:09:14 up 12:09, 1 user, load average: 0.00, 0.03, 0.05 linux-node2.oldboyedu.com: ---------- retcode: 0 stderr: stdout: 16:09:11 up 8:15, 1 user, load average: 0.15, 0.11, 0.07 [root@linux-node1 ~]# salt-ssh '*' state.sls salt.init_repo #和salt的操做相同