[size=x-small]saltstack 学习之cp模块[/size]
【基本介绍】
这里简单介绍cp模块,cp实现文件的推送和拉取。
【基本配置】
[b]cp.push - 获取minion的文件到master机器[/b]
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目录。
[code="linux"]
# salt xxx cp.push /usr/local/scripts/cut_nglog.sh
xx:
True
# 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
[/code]
cp.push_dir拉取minion上的目录到master上面,类似cp.push
[b]file.get_file - 推送master的文件到minion机器[/b]
Used to get a single file from the salt master
[code="linux"]
# salt xxx cp.get_file salt://xx.sls /root/ttt
xxx:
/root/ttt
# ls -l /root/ttt
-rw-r--r-- 1 root root 29 Oct 15 18:14 /root/ttt
[/code]
类似于salt-cp
salt-cp '*' [ options ] SOURCE DEST
[code="linux"]
# salt-cp xxx /root/salt/nagios.log /root/ttt
{'xxx': {'/root/ttt': True}}
[/code]
【其他模块】
其他模块参照[url]http://salt.readthedocs.org/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.get_file[/url]
【参考引用】
[url]http://rfyiamcool.blog.51cto.com/1030776/1360468[/url]
[url]https://salt.readthedocs.org/en/v0.17.1/ref/cli/salt-cp.html[/url]
【基本介绍】
这里简单介绍cp模块,cp实现文件的推送和拉取。
【基本配置】
[b]cp.push - 获取minion的文件到master机器[/b]
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
[code="linux"]
# salt xxx cp.push /usr/local/scripts/cut_nglog.sh
xx:
True
# 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
[/code]
cp.push_dir拉取minion上的目录到master上面,类似cp.push
[b]file.get_file - 推送master的文件到minion机器[/b]
Used to get a single file from the salt master
[code="linux"]
# salt xxx cp.get_file salt://xx.sls /root/ttt
xxx:
/root/ttt
# ls -l /root/ttt
-rw-r--r-- 1 root root 29 Oct 15 18:14 /root/ttt
[/code]
类似于salt-cp
salt-cp '*' [ options ] SOURCE DEST
[code="linux"]
# salt-cp xxx /root/salt/nagios.log /root/ttt
{'xxx': {'/root/ttt': True}}
[/code]
【其他模块】
其他模块参照[url]http://salt.readthedocs.org/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.get_file[/url]
【参考引用】
[url]http://rfyiamcool.blog.51cto.com/1030776/1360468[/url]
[url]https://salt.readthedocs.org/en/v0.17.1/ref/cli/salt-cp.html[/url]