使用yum install salt-minion -y安装salt从节点时报错如下:
解决方法:
vim /etc/yum.repos.d/saltstack.repo
[saltstack-repo]
name=SaltStack repo for RHEL/CentOS $releasever
baseurl=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest
enabled=1
gpgcheck=1
gpgkey=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest/SALTSTACK-GPG-KEY.pub
再使用yum install salt-minion -y重新安装报错如下:
yum clean all | sudo rm -r /var/cache/yum
yum clean all
yum makecache
再重新运行yum install salt-minion -y即可
在minion端配置master
vi /etc/salt/minion
master: master (大概在17行的位置)
设置master
vi /etc/salt/master
auto_accept: True
salt-key -L
添加key为Accepts Keys:
salt-key -A -y
salt执行远程命令
salt '*' cmd.run 'useradd $user_name'
salt '*' cmd.run 'userdel -r $user_name'
salt '*' cmd.run 'mkdir /home/istorm/test'
salt '*' cmd.run 'rm -rf /home/istorm/test'