标签:proc rom 系统 host tar stderr city finger file
1.salt-ssh介绍salt-ssh可以让我们不需要在受控机上安装salt-minion客户端也能够实现管理操作。
salt-ssh有两种方式实现远程管理,一种是在配置文件中记录所有客户端的信息,诸如 IP 地址、端口号、用户名、密码以及是否支持sudo等;另一种是使用密钥实现远程管理,不需要输入密码。
在 master 上安装 salt-ssh
[root@master ~]# yum -y install salt-ssh
修改配置文件,添加受控机信息
[root@master ~]# vim /etc/salt/roster
....此处省略N行
vm1:
host: 192.168.69.202
user: root
passwd: 123456
测试连通性
[root@master ~]# salt-ssh ‘*‘ test.ping
vm1:
----------
retcode:
254
stderr:
stdout:
The host key needs to be accepted, to auto accept run salt-ssh with the -i flag:
The authenticity of host ‘192.168.69.202 (192.168.69.202)‘ can‘t be established.
ECDSA key fingerprint is SHA256:Nz8CAwwL3HRh/Lvqejqa+eiV3A09xGYYfG2A/W8wRPs.
ECDSA key fingerprint is MD5:8c:b3:22:14:7a:8a:bc:34:f9:9d:3c:3a:07:8a:96:20.
Are you sure you want to continue connecting (yes/no)?
从上面的信息可以看出,第一次访问时需要输入 yes/no ,但是 saltstack 是不支持交互式操作的,所以为了解决这个问题,我们需要对其进行设置,让系统不进行主机验证。
[root@master ~]# vim ~/.ssh/config
StrictHostKeyChecking no
[root@master ~]# salt-ssh ‘*‘ test.ping
vm1:
True
安装 salt-ssh
[root@master ~]# yum -y install salt-ssh
修改roster配置文件,添加受控主机
[root@master ~]# vim /etc/salt/roster
....此处省略N行
vm1:
host: 192.168.70.205
user: root
passwd: 123456
测试连通性
[root@master ~]# salt-ssh ‘*‘ test.ping
vm1:
True
执行状态命令,初始化系统,安装salt-minion
[root@master ~]# mkdir -p /srv/salt/base/{repo,files}
[root@master ~]# \cp /etc/yum.repos.d/salt-latest.repo /srv/salt/base/repo/salt-latest.repo
[root@master ~]# cp /etc/salt/minion /srv/salt/base/files/
[root@master ~]# vim /srv/salt/base/repo.sls
salt-repo:
file.managed:
- name: /etc/yum.repos.d/salt-latest.repo
- source: salt://repo/salt-latest.repo
- user: root
- group: root
- mode: 644
[root@master ~]# vim /srv/salt/base/minion.sls
salt-minion-install:
pkg.installed:
- name: salt-minion
salt-minion-conf:
file.managed:
- name: /etc/salt/minion
- source: salt://files/minion
- user: root
- group: root
- mode: 644
- template: jinja
- default:
ID: {{ grains[‘ipv4‘] [1] }}
- require:
- pkg: salt-minion-install
salt-minion-service:
service.running:
- name: salt-minion
- enable: True
- start: True
- watch:
- file: /etc/salt/minion
[root@master ~]# salt-ssh ‘*‘ state.sls repo
[root@master ~]# salt-ssh ‘*‘ state.sls minion
[root@master ~]# salt-ssh ‘*‘ cmd.run ‘systemctl restart salt-minion‘
[root@master ~]# salt-key -a 192.168.70.205
The following keys are going to be accepted:
Unaccepted Keys:
192.168.70.205
Proceed? [n/Y] Y
Key for minion 192.168.70.205 accepted.
[root@master ~]# salt-ssh ‘*‘ state.sls minion
标签:proc rom 系统 host tar stderr city finger file
原文地址:https://blog.51cto.com/14736606/2513487