标签:
安装脚本install_salt.sh:
#!/bin/bash
####安装第三方yum源
rpm -Uvh http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel-release-6-8.noarch.rpm
###更新系统证书模块和python到最新版本
yum upgrade ca-certificates --disablerepo=epel -y
yum update python -y
##服务端安装
##yum install salt-master -y
##客户端安装
yum install salt-minion -y
##替换默认的master服务器IP
#sed -i ‘s/#master: salt/master: 10.100.60.52/g‘ /etc/salt/minion
#修改id号
#sed -i ‘s/#id:/id: LCB-P-wbs02-60.4/g‘ /etc/salt/minion
#/etc/init.d/salt-minion start
使用的一些常用命令举例:
下发文件到制定机器(注释,download_bag.sh放在salt的根目录下,默认/srv/salt,,也可自行更改)
salt ‘*‘ cp.get_file salt://download_bag.sh /home/deployer/scripts/download_bag.sh
修改文件权限
salt ‘*‘ cmd.run ‘cd /home/deployer/scripts; chown deployer:deployer *;chmod 755 *‘
远程执行本地脚本,返回日志(配置详情,salt-master服务器/srv/salt目录)
示例:salt ‘LCB-U-touch02-123‘ state.sls touch-webapp/download_bag
top.sls配置:
base:
‘*‘:
- touch-webapp/download_bag.init
download_bag.init配置:vi /srv/salt/touch-webapp/download_bag/init.sls
shell_download:
cmd.script:
- source: salt://touch-webapp/download_bag/download_bag.sh
- mode: 755
- user: deployer
~
标签:
原文地址:http://www.cnblogs.com/franjia/p/5852526.html