• [Ansible]copy 模块


    官网

    [root@ceph1 ~]# cat a.repo
    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
    metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
    failovermethod=priority
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    
    [epel-debuginfo]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
    metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch&infra=$infra&content=$contentdir
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    
    [epel-source]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Source
    #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
    metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch&infra=$infra&content=$contentdir
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    
    # 将a.repo传送到其他服务器
    [root@ceph1 ~]# ansible webservers -m copy -a "src=./a.repo dest=/tmp/a.repo"
    
    # 修改配置文件
    [root@ceph1 ~]# echo 'add' >> a.repo
    
    # 再次发送带备份参数
    [root@ceph1 ~]# ansible all -m copy -a "src=./a.repo dest=/tmp/a.repo backup=yes"
    
    # 查看配置文件备份
    [root@ceph1 ~]# ansible all -m shell -a "ls -l /tmp/*.repo*"
    ceph3 | CHANGED | rc=0 >>
    -rw-r--r-- 1 root root 1054 9月  14 12:00 /tmp/a.repo
    -rw-r--r-- 1 root root 1050 9月  14 12:00 /tmp/a.repo.23055.2020-09-14@12:00:57~
    ceph2 | CHANGED | rc=0 >>
    -rw-r--r-- 1 root root 1054 9月  14 12:00 /tmp/a.repo
    
    # 修改文件用户权限
    [root@ceph1 ~]# ansible all -m copy -a "src=./a.repo dest=/tmp/a.repo owner=nobody group=nobody"
    [root@ceph1 ~]# ansible all -m shell -a "ls -l /tmp/*.repo*"
    ceph3 | CHANGED | rc=0 >>
    -rw-r--r-- 1 nobody nobody 1054 9月  14 12:00 /tmp/a.repo
    -rw-r--r-- 1 root   root   1050 9月  14 12:00 /tmp/a.repo.23055.2020-09-14@12:00:57~
    ceph2 | CHANGED | rc=0 >>
    -rw-r--r-- 1 nobody nobody 1054 9月  14 12:00 /tmp/a.repo
    
    # 修改目的文件权限
    [root@ceph1 ~]# ansible all -m copy -a "src=./a.repo dest=/tmp/a.repo mode=0777"
    [root@ceph1 ~]# ansible all -m shell -a "ls -l /tmp/*.repo*"
    ceph3 | CHANGED | rc=0 >>
    -rwxrwxrwx 1 nobody nobody 1054 9月  14 12:00 /tmp/a.repo
    -rw-r--r-- 1 root   root   1050 9月  14 12:00 /tmp/a.repo.23055.2020-09-14@12:00:57~
    ceph2 | CHANGED | rc=0 >>
    -rwxrwxrwx 1 nobody nobody 1054 9月  14 12:00 /tmp/a.repo
    

    END

  • 相关阅读:
    js前端分享功能
    git常用命令
    webstorm中.vue报错
    页面重绘重排
    浏览器渲染引擎总结
    javascript中的this总结
    cookie、session、sessionid 与jsessionid
    promise和Angular中的 $q, defer
    C++11之nullptr
    C++ 输入ctrl+z 不能再使用cin的问题
  • 原文地址:https://www.cnblogs.com/leoshi/p/13666727.html
Copyright © 2020-2023  润新知