问题描述
下面是我的剧本,帮助将一组文件从远程源传输到本地目录。
- name: "Play 1.5"
hosts: "{{ groups['dest_nodes'] | default(groups['all']) }}"
serial: 1
gather_facts: false
vars:
ansible_host_key_checking: false
ansible_ssh_extra_args: -o StrictHostKeyChecking=no -o ConnectionAttempts=5
tasks:
- find:
paths: "{{ homedir.stdout_lines[0] | trim }}"
recurse: no
file_type: any
hidden: yes
patterns:
- "(.*txt)$"
- "(.*sh.*)$"
- "(.*bash.*)$"
- "(.*ksh.*)$"
- "(.*profile.*)$"
use_regex: yes
register: to_copy
- debug:
msg: "FOUNDDD {{ item.path}}"
with_items: "{{ to_copy.files }}"
- name: copying from "{{ inventory_hostname }}" to this ansible server.
synchronize:
src: "{{ item.path }}"
dest: "{{ playbook_dir }}/homedirbackup/{{ inventory_hostname }}/{{ dtime }}/"
mode: pull
copy_links: yes
with_items:
- "{{ to_copy.files }}"
它将一些文件从远程目录复制到本地目录 "{{ playbook_dir }}/homedirbackup/{{ inventory_hostname }}/{{ dtime }}/"
,但随后中途冻结并超时,即未完成所有文件的传输。
以下输出显示它传输了两个文件 /opt/oracle/checkservice.sh
和 /opt/oracle/stopservice.sh
,但在尝试传输 .profile.bak.configurevwsapi.2018.11.08-21.07.49
时冻结/从未返回
<remotehost35> ESTABLISH LOCAL CONNECTION FOR USER: localuser
<remotehost35> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'
changed: [remotehost35] => (item={u'uid': 600000014,u'woth': False,u'mtime': 1603787134.107684,u'inode': 100717,u'isgid': False,u'size': 651,u'isuid': False,u'isreg': True,u'gid': 63855,u'ischr': False,u'wusr': True,u'xoth': False,u'rusr': True,u'nlink': 1,u'issock': False,u'rgrp': True,u'path': u'/opt/oracle/checkservice.sh',u'xusr': True,u'atime': 1626695687.6682055,u'isdir': False,u'ctime': 1603787134.108393,u'isblk': False,u'wgrp': False,u'xgrp': False,u'dev': 1301375156245,u'roth': True,u'isfifo': False,u'mode': u'0744',u'islnk': False}) => {
"changed": true,"cmd": "/bin/rsync --delay-updates -F --compress --copy-links --archive --rsh=/usr/share/centrifydc/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKNownHostsFile=/dev/null --out-format=<<CHANGED>>%i %n%L oracle@remotehost35:/opt/oracle/checkservice.sh /web/playbooks/automation/aesstartup/homedirbackup/remotehost35/2021-07-19-08-10-07/","invocation": {
"module_args": {
"_local_rsync_path": "rsync","_substitute_controller": false,"archive": true,"checksum": false,"compress": true,"copy_links": true,"delete": false,"dest": "/web/playbooks/automation/aesstartup/homedirbackup/remotehost35/2021-07-19-08-10-07/","dest_port": null,"dirs": false,"existing_only": false,"group": null,"links": null,"mode": "pull","owner": null,"partial": false,"perms": null,"private_key": null,"recursive": null,"rsync_opts": null,"rsync_path": null,"rsync_timeout": 0,"set_remote_user": true,"src": "oracle@remotehost35:/opt/oracle/checkservice.sh","ssh_args": null,"times": null,"verify_host": false
}
},"item": {
"atime": 1626695687.6682055,"ctime": 1603787134.108393,"dev": 1301375156245,"gid": 63855,"inode": 100717,"isblk": false,"ischr": false,"isdir": false,"isfifo": false,"isgid": false,"islnk": false,"isreg": true,"issock": false,"isuid": false,"mode": "0744","mtime": 1603787134.107684,"nlink": 1,"path": "/opt/oracle/checkservice.sh","rgrp": true,"roth": true,"rusr": true,"size": 651,"uid": 600000014,"wgrp": false,"woth": false,"wusr": true,"xgrp": false,"xoth": false,"xusr": true
},"msg": ">f+++++++++ checkservice.sh\n","rc": 0,"stdout_lines": [
">f+++++++++ checkservice.sh"
]
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/synchronize.py
<remotehost35> ESTABLISH LOCAL CONNECTION FOR USER: localuser
<remotehost35> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'
changed: [remotehost35] => (item={u'uid': 600000014,u'mtime': 1603787257.2357972,u'inode': 100721,u'size': 266,u'path': u'/opt/oracle/stopservice.sh',u'atime': 1626695689.0853248,u'ctime': 1603787257.236637,"cmd": "/bin/rsync --delay-updates -F --compress --copy-links --archive --rsh=/usr/share/centrifydc/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKNownHostsFile=/dev/null --out-format=<<CHANGED>>%i %n%L oracle@remotehost35:/opt/oracle/stopservice.sh /web/playbooks/automation/aesstartup/homedirbackup/remotehost35/2021-07-19-08-10-07/","src": "oracle@remotehost35:/opt/oracle/stopservice.sh","item": {
"atime": 1626695689.0853248,"ctime": 1603787257.236637,"inode": 100721,"mtime": 1603787257.2357972,"path": "/opt/oracle/stopservice.sh","size": 266,"msg": ">f+++++++++ stopservice.sh\n","stdout_lines": [
">f+++++++++ stopservice.sh"
]
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/synchronize.py
<remotehost35> ESTABLISH LOCAL CONNECTION FOR USER: localuser
<remotehost35> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'
<---- HANGS HERE and never returns ---->
下面是远程主机的两个文件的列表,我从那里在我的 ansible 主机上本地拉取它们。
oracle@remotehost35:~$ ls -ltraq /opt/oracle/checkservice.sh
-rwxr--r-- 1 oracle oinstall 651 Oct 27 2020 /opt/oracle/checkservice.sh
oracle@remotehost35:~$ ls -ltraq /opt/oracle/stopservice.sh
-rwxr--r-- 1 oracle oinstall 266 Oct 27 2020 /opt/oracle/stopservice.sh
以下是未传输的文件,我猜(但是,我不确定)这就是 ansible 下一步尝试传输的文件。
oracle@remotehost35:~$ ls -ltrqa .profile.bak.configurevwsapi.2018.11.08-21.07.49
-rw-r--r-- 1 oracle oinstall 2215 Nov 8 2018 .profile.bak.configurevwsapi.2018.11.08-21.07.49
ok: [remotehost35] => (item={u'uid': 600000014,u'mtime': 1541732869.0,u'inode': 174300,u'size': 2215,u'path': u'/opt/oracle/.profile.bak.configurevwsapi.2018.11.08-21.07.49',u'xusr': False,u'atime': 1626044466.6511383,u'ctime': 1564193798.4474971,u'mode': u'0644',u'islnk': False}) => {
"changed": false,"item": {
"atime": 1626044466.6511383,"ctime": 1564193798.4474971,"inode": 174300,"mode": "0644","mtime": 1541732869.0,"path": "/opt/oracle/.profile.bak.configurevwsapi.2018.11.08-21.07.49","size": 2215,"xusr": false
},"msg": "FOUNDDD /opt/oracle/.profile.bak.configurevwsapi.2018.11.08-21.07.49"
}
以上输出在 ansible 上的调试级别为 4 -vvvv
。
你能说明为什么在循环几次迭代后传输会冻结吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)