目录标题
1. copy模块
[root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt" # 将ansible主机的/testdir/copytest文件放到testB的dest=/opt中
server3 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"checksum": "df800445bb74b4abb144b3f9bf03f90aa9618f4c",
"dest": "/opt/copytest",
"gid": 0,
"group": "root",
"md5sum": "f61d358bbdd6a9bd2e93322023a4e29d",
"mode": "0644",
"owner": "root",
"size": 14,
"src": "/root/.ansible/tmp/ansible-tmp-1584847258.15-102377415690502/source",
"state": "file",
"uid": 0
}
[root@server4 testdir]# ansible testB -m copy -a "content="westos\nlinux\n" dest=/opt/test" # 将内容content="westos\nlinux\n写入到testB的dest=/opt/test文件中
[root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt force=no" # force=no表示不覆盖dest=/opt中的coputest
[root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt backup=yes" # 将ansible主机的/testdir/copytest拷贝到testB中的dest=/opt 目录中,如果copytest内容不一样将会对dest=/opt 中的copytest进行备份
[root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt owner=zjy" # 指定/opt中copytest文件的拥有者,文件内容不改变
[root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt group=zjy" # 指定/opt中copytest文件的组
[root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt mode=0640" # # 指定/opt中copytest文件的权限