############################################################
*
* SaltStack远程分发hosts配置文件
############################################################
[[email protected] dns]# mkdir -p /srv/salt/hosts/files
[[email protected] dns]# cp /etc/hosts /srv/salt/hosts/files/
#分发/etc/resolv.conf相关的配置文件
[[email protected] dns]# tree /srv/salt/hosts/
/srv/salt/hosts/
├── files
│?? └── hosts
└── hosts-install.sls
[[email protected] dns]# cat /srv/salt/hosts/hosts-install.sls
/etc/hosts:
file.managed:
- source: salt://hosts/files/hosts
- user: root
- group: root
- mode: 644
[[email protected] dns]# cat /srv/salt/hosts/files/hosts
127.0.0.1 localhost
192.168.44.5 LB01
192.168.44.6 LB02
192.168.44.7 WEB01 www.yehaixiao.com bbs.yehaixiao.con status.yehaixiao.com
192.168.44.8 WEB02 www.yehaixiao.cn bbs.yehaixiao.cn status.yehaixiao.cn
192.168.44.51 DB01
192.168.44.31 NFS01
192.168.44.41 BACKUP
192.168.44.61 M01
192.168.44.71 YUM01
192.168.44.81 Zabbix01
#salt-v11
#服务端执行命令
salt ‘WEB0?‘ state.sls hosts.hosts-install
[[email protected] dns]# cat /srv/salt/top.sls
base:
‘*‘:
- apache.apache-install
- dns.dns-install
- hosts.hosts-install
#测试执行,没问题才更新到客户端
[[email protected] salt]# salt ‘WEB01‘ state.highstate test=True
原文地址:http://blog.51cto.com/yehaixiao/2125093