1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| 2).copy模块,批量发送文件到被管理端或向被管理端文件写内容 copy模块下常用参数: src: 推送数据的源文件信息 dest: 推送数据的目录路径 backup: 对推送传送过去的文件,进行原文件备份,再接收新文件 content: 直接批量在皴管理端文件中添加内容 group: 将本地文件推送到远端,指定文件属组信息 owner: 将本地文件推送到远端,指定文件属主信息 mode: 将本地文件推动到远端,指定文件权限信息
(1).将管理端(ansible机器)上本地文件(/tmp/a.txt)批量发送给被管理端(/tmp/目录): copy模块注意:所有被管理端需要安装: libselinux-python,此处为192.168.171.129和192.168.171.130上)[root@localhost ~] 管理端: [root@node1 ~] [root@node1 ~] 11111 [root@node1 ~] 192.168.88.163 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "checksum": "659f5f85766824a4290371a2abfaeb007cd0af4a", "dest": "/tmp/a.txt", "gid": 0, "group": "root", "md5sum": "fa8f294721ab3fbb37793c68ff2cf09b", "mode": "0644", "owner": "root", "size": 6, "src": "/root/.ansible/tmp/ansible-tmp-1692524423.9-3528-235526458743393/source", "state": "file", "uid": 0 } 192.168.88.162 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "checksum": "659f5f85766824a4290371a2abfaeb007cd0af4a", "dest": "/tmp/a.txt", "gid": 0, "group": "root", "md5sum": "fa8f294721ab3fbb37793c68ff2cf09b", "mode": "0644", "owner": "root", "size": 6, "src": "/root/.ansible/tmp/ansible-tmp-1692524423.91-3526-156070185170456/source", "state": "file", "uid": 0 }
|