共计 1081 个字符,预计需要花费 3 分钟才能阅读完成。
一、fetch 模块
fetch 模块与 copy 模块类似,但作用相反。用于把远程机器的文件拷贝到本地。
https://docs.ansible.com/ansible/latest/modules/fetch_module.html#fetch-module
将 group1 组机器的 /opt/readme 拷贝到 manage01 的 /opt 目录
注意: 不管是拷贝多个机器还是一个机器的文件,在管理机本地目录都会按照
IP/ 路径 / 文件名
的方式命名,防止冲突
[root@manage01 ~]# ansible -m fetch group1 -a "src=/opt/readme dest=/opt"
192.168.98.203 | CHANGED => {"changed": true,
"checksum": "f8182e9ccdbe6efd13eb36a056a7db203fe66e40",
"dest": "/opt/192.168.98.203/opt/readme",
"md5sum": "f8c2686842f9fa79361e8928867a1983",
"remote_checksum": "f8182e9ccdbe6efd13eb36a056a7db203fe66e40",
"remote_md5sum": null
}
192.168.98.202 | CHANGED => {"changed": true,
"checksum": "f8182e9ccdbe6efd13eb36a056a7db203fe66e40",
"dest": "/opt/192.168.98.202/opt/readme",
"md5sum": "f8c2686842f9fa79361e8928867a1983",
"remote_checksum": "f8182e9ccdbe6efd13eb36a056a7db203fe66e40",
"remote_md5sum": null
}
192.168.98.201 | CHANGED => {"changed": true,
"checksum": "f8182e9ccdbe6efd13eb36a056a7db203fe66e40",
"dest": "/opt/192.168.98.201/opt/readme",
"md5sum": "f8c2686842f9fa79361e8928867a1983",
"remote_checksum": "f8182e9ccdbe6efd13eb36a056a7db203fe66e40",
"remote_md5sum": null
}
二、学习视频
正文完
星哥玩云-微信公众号