saltstack 文件下发与拉取
salt的文件下发,使用cp.get_file函数,空文件是不生效的
[email protected] base]# salt ‘*‘ cmd.run ‘ls /root/‘ hadm.com: anaconda-ks.cfg install.log install.log.syslog had6.com: abc anaconda-ks.cfg dump.rdb install.log install.log.syslog put1 puth1 test test1 had5.com: abc anaconda-ks.cfg install.log install.log.syslog put1 test test1 [[email protected] base]# salt ‘*‘ cp.get_file salt://files/test1 /root/test_00 hadm.com: /root/test_00 had6.com: /root/test_00 had5.com: /root/test_00 [[email protected] base]# salt ‘*‘ cmd.run ‘ls /root/‘ hadm.com: anaconda-ks.cfg install.log install.log.syslog test_00 had5.com: abc anaconda-ks.cfg install.log install.log.syslog put1 test test1 test_00 had6.com: abc anaconda-ks.cfg dump.rdb install.log install.log.syslog put1 puth1 test test1 test_00
salt文件拉取使用cp.push,需要在master配置文件中添加以下配置,并重启master:
fileserver_backend:
- roots
- minion
file_recv: True
示例:
[[email protected] minions]# salt ‘had5.com‘ cp.push /root/put1 had5.com: True [[email protected] minions]# salt ‘hadm.com‘ cp.list_master_dirs hadm.com: - . - _returners - files - had5.com/root - mysqlbackup --文件put1已经拉取到/var/cache/salt/master/minions/minion_id/files目录 [[email protected] minions]# ll /var/cache/salt/master/minions/had5.com/files/root/put1 --我们还可以使用salt://minion_id/来访问拉取过来的文件。 [[email protected] minions]# salt ‘had6.com‘ cp.get_file salt://had5.com/root/put1 /root/put1 had6.com: /root/put1 [[email protected] minions]# salt ‘had6.com‘ cmd.run ‘ls /root/put1‘ had6.com: /root/put1
时间: 2024-11-02 11:49:52