saltstack 学习之cp模块
【基本介绍】
这里简单介绍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
[iyunv@vpn ~]# salt xxx cp.push /usr/local/scripts/cut_nglog.sh
xx:
True
[iyunv@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
[iyunv@vpn ~]# salt xxx cp.get_file salt://xx.sls /root/ttt
xxx:
/root/ttt
[iyunv@xxx ~]# ls -l /root/ttt
-rw-r--r-- 1 root root 29 Oct 15 18:14 /root/ttt