# Ansible play freezes and never completes after copying part of the files using synchronize module

**URL:** <https://forum.ansible.com/t/ansible-play-freezes-and-never-completes-after-copying-part-of-the-files-using-synchronize-module/35519>\
**Category:** Ansible Project\
**Created:** [July 19, 2021, 1:49pm UTC](https://forum.ansible.com/t/ansible-play-freezes-and-never-completes-after-copying-part-of-the-files-using-synchronize-module/35519 "2021-07-19T13:49:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Easy\_King](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@Easy\_King](https://forum.ansible.com/u/Easy_King)\
**Post date:** [July 19, 2021, 1:49pm UTC](https://forum.ansible.com/t/ansible-play-freezes-and-never-completes-after-copying-part-of-the-files-using-synchronize-module/35519/1 "2021-07-19T13:49:45Z")

</div>

Below is my playbook that helps transfer a set of files from remote source to local directory.

- 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 }}”

It copies a few files from remote to local directory “{{ playbook\_dir }}/homedirbackup/{{ inventory\_hostname }}/{{ dtime }}/” but then freezes midway and times-out i.e does not complete the transfer of all the files.

The below output shows that it transferred two files /opt/oracle/checkservice.sh & /opt/oracle/stopservice.sh but froze / never returned while trying to transfer .profile.bak.configurevwsapi.2018.11.08-21.07.49

ESTABLISH LOCAL CONNECTION FOR USER: localuser

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=\<\>%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

ESTABLISH LOCAL CONNECTION FOR USER: localuser

EXEC /bin/sh -c ‘/usr/bin/python2 && sleep 0’

changed: [remotehost35] =\> (item={u’uid’: 600000014, u’woth’: False, u’mtime’: 1603787257.2357972, u’inode’: 100721, u’isgid’: False, u’size’: 266, 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/stopservice.sh’, u’xusr’: True, u’atime’: 1626695689.0853248, u’isdir’: False, u’ctime’: 1603787257.236637, 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=\<\>%i %n%L oracle@remotehost35:/opt/oracle/stopservice.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/stopservice.sh”,

“ssh\_args”: null,

“times”: null,

“verify\_host”: false

}

},

“item”: {

“atime”: 1626695689.0853248,

“ctime”: 1603787257.236637,

“dev”: 1301375156245,

“gid”: 63855,

“inode”: 100721,

“isblk”: false,

“ischr”: false,

“isdir”: false,

“isfifo”: false,

“isgid”: false,

“islnk”: false,

“isreg”: true,

“issock”: false,

“isuid”: false,

“mode”: “0744”,

“mtime”: 1603787257.2357972,

“nlink”: 1,

“path”: “/opt/oracle/stopservice.sh”,

“rgrp”: true,

“roth”: true,

“rusr”: true,

“size”: 266,

“uid”: 600000014,

“wgrp”: false,

“woth”: false,

“wusr”: true,

“xgrp”: false,

“xoth”: false,

“xusr”: true

},

“msg”: “\>f+++++++++ stopservice.sh\n”,

“rc”: 0,

“stdout\_lines”: [

“\>f+++++++++ stopservice.sh”

]

}

Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/synchronize.py

ESTABLISH LOCAL CONNECTION FOR USER: localuser

EXEC /bin/sh -c ‘/usr/bin/python2 && sleep 0’

\<---- HANGS HERE and never returns ----\>

Below are the listing of both the files of the remote host from where i m pulling them locally on my ansible host.

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

Below is the file that did not get transferred and i guess (however, i m not sure) thats the file ansible was trying next to transfer.

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

Here is the stat of the file that did not get transferred and ansible froze

ok: [remotehost35] =\> (item={u’uid’: 600000014, u’woth’: False, u’mtime’: 1541732869.0, u’inode’: 174300, u’isgid’: False, u’size’: 2215, 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/.profile.bak.configurevwsapi.2018.11.08-21.07.49’, u’xusr’: False, u’atime’: 1626044466.6511383, u’isdir’: False, u’ctime’: 1564193798.4474971, u’isblk’: False, u’wgrp’: False, u’xgrp’: False, u’dev’: 1301375156245, u’roth’: True, u’isfifo’: False, u’mode’: u’0644’, u’islnk’: False}) =\> {

“changed”: false,

“item”: {

“atime”: 1626044466.6511383,

“ctime”: 1564193798.4474971,

“dev”: 1301375156245,

“gid”: 63855,

“inode”: 174300,

“isblk”: false,

“ischr”: false,

“isdir”: false,

“isfifo”: false,

“isgid”: false,

“islnk”: false,

“isreg”: true,

“issock”: false,

“isuid”: false,

“mode”: “0644”,

“mtime”: 1541732869.0,

“nlink”: 1,

“path”: “/opt/oracle/.profile.bak.configurevwsapi.2018.11.08-21.07.49”,

“rgrp”: true,

“roth”: true,

“rusr”: true,

“size”: 2215,

“uid”: 600000014,

“wgrp”: false,

“woth”: false,

“wusr”: true,

“xgrp”: false,

“xoth”: false,

“xusr”: false

},

“msg”: “FOUNDDD /opt/oracle/.profile.bak.configurevwsapi.2018.11.08-21.07.49”

}

The above output is with debug level 4 -vvvv on ansible.

Can you please suggest why the transfer freezes after a few iterations of the loop?
