使用Ansible,我希望用当前时间戳和755权限将所有文件从redhat localhost /app/tmpfiles/文件夹转移到远程服务器上/was/IBM/BACKUP/00005/。
下面的命令显示我确实在本地主机上有一个文件:
[localuser@localhost]$ ls -ltr /app/tmpfiles/*
-rw-rw-r-- 1 localuser user 12 Sep 13 15:53 /app/tmpfiles/testingjsp4.jsp下面是我的这一任务的可操作的剧本。
- name: Play 1
host: remoteaixhost
- name: "Backup on Destination Server"
tags: validate
local_action: command rsync --delay-updates -F --compress --chmod=755 "--rsh=/usr/bin/ssh -S none -i /app/my_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" "--out-format=<<CHANGED>>%i %n%L" "{{ playbook_dir }}/tmpfiles/*" "{{ USER }}@{{ inventory_hostname }}":"{{ vars[inventory_hostname] }}/BACKUP/{{ Number }}/"
run_once: true运行上面的剧本失败,下面是ansible的错误日志:
目标服务器远程服务器上的
任务备份。**致命: remoteaixhost -> localhost:=>!=>{“已更改”:true,"cmd":"rsync",“-delay”,"-F",“-compress”,“-chmod=755”,“-rsh=/usr/bin/ssh -S n -i /app/my_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null",”-out-format=<>%i %n%L","/app/tmpfiles/_",“user2 2@remoteaixhost:/was/IBM/BACKUP/00005/”、"delta":"0:00:00.228097“、"end":"2019-10-04 00: 23 :09.103525”、"msg":“非零返回码”、"rc":23、"start":"2019-10-04 00:23:08.875428","stderr":“警告:将‘远程主机’(RSA)永久添加到已知主机列表中。\r\n此系统仅供授权用户使用。未经授权或超出权限使用这一计算机系统的个人,必须由系统人员对其在该系统上的所有活动进行监测和记录。在监测个人不当使用本系统的过程中,或在系统维护过程中,授权用户的活动也可能受到监视。任何使用这一系统的人都明确同意这种监测,并被告知,如果这种监测揭示了犯罪活动的可能证据,系统人员可以向执法人员提供这种监测的证据\n nrsync: link_stat \“app/tmpfiles/__”失败:没有这样的文件或目录(2)\nrsync错误:一些文件/吸引器没有被转移(见先前的错误)(代码23)在main.c(1178) sender=3.1.2上,"stderr_lines":“警告:将‘远程主机’永久添加到已知主机列表中。”,“此系统仅供授权用户使用。”未经授权或超出权限使用这一计算机系统的个人,必须由系统人员对其在该系统上的所有活动进行监测和记录。在监测个人不当使用本系统的过程中,或在系统维护过程中,授权用户的活动也可能受到监视。任何使用这一系统的人都明确同意进行这种监视,并被告知,如果这种监测揭示了犯罪活动的可能证据,系统人员可以向执法人员提供这种监视的证据,"rsync: link_stat \“/app/tmpfiles/*\\”failed: No此类文件或目录(2)","rsync错误:一些文件/吸引物没有被转移(见先前的错误)(代码23)在main.c(1178) sender=3.1.2"],“stdout:”,"stdout_lines":[]}
不再有主人了
RECAP *********************************************************************远程主机: ok=8 changed=4 unreachable=0
failed=1 skipped=6 rescued=0 ignored=0 localhost
:ok=4 changed=2 unreachable=0 failed=0 skipped=1
rescued=0 ignored=0
生成步骤'Execute‘标记为failure : FAILURE
在输出中困扰我的一件事是“致命的:远程托管-> localhost”,当我们实际指定local_action时,.Why会说“远程托管-> localhost”,而我希望它显示如下:"localhost ->远程托管“,但是,我不确定我的观察结果是否有关,解决方案是什么,以及这是否有助于我们朝着正确的方向看。
注意:我还试着从上面的rsync命令中移除收敛器,如下所示:
rsync --delay-updates -F --compress --chmod=755 "--rsh=/usr/bin/ssh -S none -i /app/my_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" "--out-format=<<CHANGED>>%i %n%L" "{{ playbook_dir }}/tmpfiles/" "{{ USER }}@{{ inventory_hostname }}":"{{ vars[inventory_hostname] }}/BACKUP/{{ Number }}/"但是,没有收到错误,文件/s不会被复制到目标主机。
我尝试手动在localhost上运行rsync命令,如下所示:
# with aistrick the copy is successful:
[localuser@localhost]$ rsync --delay-updates -F --compress --chmod=755 "--rsh=/usr/bin/ssh -S none -i /app/my_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --out-format="<<CHANGED>>%i %n%L" /app/tmpfiles/* user2@remoteaixhost:/was/IBM/BACKUP/00005/
Warning: Permanently added 'remoteaixhost' (RSA) to the list of known hosts.
This system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to the law enforcement officials
<<CHANGED>><f+++++++++ testingjsp4.jsp
[localuser@localhost]$ echo $?
0
# without aistrick the files do not get copied over:
[localuser@localhost]$ rsync --delay-updates -F --compress --chmod=755 "--rsh=/usr/bin/ssh -S none -i /app/my_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --out-format="<<CHANGED>>%i %n%L" /app/tmpfiles/ user2@remoteaixhost:/was/IBM/BACKUP/00005/
Warning: Permanently added 'remoteaixhost' (RSA) to the list of known hosts.
This system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to the law enforcement officials
skipping directory .
[localuser@localhost]$ echo $?
0你能建议一下吗?
发布于 2019-10-10 17:13:19
local_action: command rsync -r --delay-updates -F --compress --chmod=755 "--rsh=/usr/bin/ssh -S none -i /app/my_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" "--out-format=<<CHANGED>>%i %n%L" {{ playbook_dir }}/tmpfiles/*.log "{{ USER }}@{{ inventory_hostname }}":"{{ vars[inventory_hostname] }}/BACKUP/{{ Number }}/"这是可行的,我删除了-> {{ playbook_dir }/tmpfiles/*..log周围的双引号。
https://stackoverflow.com/questions/58225960
复制相似问题