salt数据同步方式
方式一:
minion自动向master进行数据同步:
默认是60秒自动同步一次数据
自动同步时间间隔由参数loop_interval来决定(minion端)
[root@scj salt]# grep loop_interval /etc/salt/minion
# The loop_interval sets how long in seconds the minion will wait between
#loop_interval: 60
如果我们想让minion永远不要自动同步,可以把这个参数值改大一点
loop_interval: 3153600000 (设置100年同步一次)
方式二:
master端通过执行命令进行数据同步:
测试配置是否正确,并没有真正的推送数据:
salt ‘*‘ state.highstate -v test
salt ‘*‘ state.highstate -v test=true
salt ‘*‘ state.highstate -v test=True
向所有minion推送所有数据:
salt ‘*‘ state.highstate
向某一台minion推送所有数据:
salt ‘192.168.186.129‘ state.highstate
向某一个分组推送所有数据:
salt -N ‘BJwebgroup‘ state.highstate
向所有minion只推送web这个模板目录的数据
salt ‘*‘ state.sls web
注意:
[root@scj salt]# cat top.sls
base:
‘BJwebgroup‘:
- match: nodegroup
- web
向所有minion只推送web模板下面的httpd.sls文件:
salt ‘*‘ state.sls web.httpd
注意:
[root@scj web]# pwd
/srv/salt/web
[root@scj web]# ls
files httpd.sls init.sls
向所有minion只推送web模板下面php目录下面的conf.sls文件:
salt ‘*‘ state.sls web.php.conf
注意:
[root@scj php]# pwd
/srv/salt/web/php
[root@scj php]# ls
conf.sls
附加:
salt常用命令:
salt ‘*‘ grains.ls 查看grains分类
salt ‘*‘ grains.items 查看grains所有信息
salt ‘*‘ grains.item os 查看grains某个信息
salt ‘*‘ pillar.items 查看pillar所有信息
salt ‘*‘ pillar.item users 查看pillar某个信息
[root@scj salt]# salt ‘*‘ grains.item os
192.168.186.129:
----------
os:
CentOS
[root@scj salt]# salt ‘*‘ grains.item fqdn
192.168.186.129:
----------
fqdn:
scj.51.com
[root@scj salt]# salt ‘*‘ grains.item host
192.168.186.129:
----------
host:
scj
salt ‘匹配正则‘ state.highstate 匹配正则
[root@scj salt]# salt ‘*‘ state.highstate
salt -N ‘GroupName‘ state.highstate 指定某个组
[root@scj salt]#salt -N ‘BJwebgroup‘ state.highstate
salt -L ‘minion1,minion2,minion3‘ state.highstate 指定多个minion
[root@scj salt]# salt -L ‘192.168.186.129,192.168.186.128‘ state.sls web.php.conf
本文出自 “见” 博客,请务必保留此出处http://732233048.blog.51cto.com/9323668/1640990
原文:http://732233048.blog.51cto.com/9323668/1640990