【基本介绍】
这里简单介绍cp模块,cp实现文件的推送和拉取。
【基本配置】
cp.push - 获取minion的文件到master机器
Push a file from the minion up to the master, the file will be saved to the salt master in the master's minion files cachedir (defaults to /var/cache/salt/master/minions/minion-id/files)
Since this feature allows a minion to push a file up to the master server it is disabled by default for security purposes. To enable, set file_recv to True in the master configuration file, and restart the master.
配置支持从minion拉取文件,并配置cache目录。
# Allow minions to push files to the master. This is disabled by default, for # security purposes. file_recv: True # Directory to store job and cache data: cachedir: /var/cache/salt/master
[root@vpn ~]# salt xxx cp.push /usr/local/scripts/cut_nglog.sh xx: True [root@vpn ~]# ls -l /var/cache/salt/master/minions/xxx/files/usr/local/scripts/cut_nglog.sh -rw-r--r-- 1 root root 2099 Oct 15 18:05 /var/cache/salt/master/minions/xxx/files/usr/local/scripts/cut_nglog.sh
cp.push_dir拉取minion上的目录到master上面,类似cp.push
file.get_file - 推送master的文件到minion机器
Used to get a single file from the salt master
[root@vpn ~]# salt xxx cp.get_file salt://xx.sls /root/ttt xxx: /root/ttt [root@xxx ~]# ls -l /root/ttt -rw-r--r-- 1 root root 29 Oct 15 18:14 /root/ttt
类似于salt-cp
salt-cp '*' [ options ] SOURCE DEST
[root@vpn ~]# salt-cp xxx /root/salt/nagios.log /root/ttt {'xxx': {'/root/ttt': True}}
【其他模块】
其他模块参照 http://salt.readthedocs.org/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.get_file
【参考引用】
http://rfyiamcool.blog.51cto.com/1030776/1360468
https://salt.readthedocs.org/en/v0.17.1/ref/cli/salt-cp.html