[Ansible]copy 模組
阿新 • • 發佈:2020-09-14
[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