ansible:copy模块

目录标题


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
}
  1. [root@server4 testdir]# ansible testB -m copy -a "content="westos\nlinux\n" dest=/opt/test" # 将内容content="westos\nlinux\n写入到testB的dest=/opt/test文件中
  2. [root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt force=no" # force=no表示不覆盖dest=/opt中的coputest
  3. [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进行备份
  4. [root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt owner=zjy" # 指定/opt中copytest文件的拥有者,文件内容不改变
  5. [root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt group=zjy" # 指定/opt中copytest文件的组
  6. [root@server4 testdir]# ansible testB -m copy -a "src=/testdir/copytest dest=/opt mode=0640" # # 指定/opt中copytest文件的权限
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值