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

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?