Master:
curl -L http://bootstrap.saltstack.org | sudo sh -s -- -M -N
yum search salt-ssh
Slave:
wget -O - http://bootstrap.saltstack.org | sudo sh
yum install salt-minion
客户端配置:
Master: 192.168.1.1
#识别ID
id: test
启动客户端:
/etc/init.d/salt-minion start
服务器端确认:
salt-key -A
执行模块命令:
salt '*' test.ping
执行shell命令:
salt '*' cmd.run "uptime"
执行脚本命令:
mkdir -p /srv/salt/scripts/
cat > /srv/salt/scripts/test.sh << EOF
#!/bin/bash
echo "test" > /tmp/test.txt
echo $1
echo $2
echo $3
EOF
salt '*' cmd.script salt://scripts/test.sh "aa bb cc"
同步服务器状态,安装git:
cat >/srv/salt/git.sls << EOF
git:
pkg:
- installed
EOF
salt '*' state.sls git
查看节点信息:
salt '*' grains.ls 查看grains分类
salt '*' grains.items 查看grains所有信息
salt '*' grains.item osrelease 查看grains某个信息
内置模块:http://docs.saltstack.com/ref/modules/all/index.html
标签:none