# Ansible task failure stating shared connection closed module failure

**URL:** <https://forum.ansible.com/t/ansible-task-failure-stating-shared-connection-closed-module-failure/5906>\
**Category:** Get Help\
**Tags:** playbook, awx, collections, ansible-core\
**Created:** [May 21, 2024, 10:00am UTC](https://forum.ansible.com/t/ansible-task-failure-stating-shared-connection-closed-module-failure/5906 "2024-05-21T10:00:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![husnain\_taja](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@husnain\_taja](https://forum.ansible.com/u/husnain_taja)\
**Post date:** [May 21, 2024, 10:00am UTC](https://forum.ansible.com/t/ansible-task-failure-stating-shared-connection-closed-module-failure/5906/1 "2024-05-21T10:00:56Z")

</div>

Hi,

I am executing AWX job template which calls one playbook to copy configuration file on the managed node.I have this task which check’s the file existence using stat module

```auto
- name: Check conf file stat
  stat:
    path: "{{ install_dir }}/telegraf.d/{{ template | regex_replace('.template') }}_{{ monitor_name }}.conf"
  register: conf_file_data
  become: true
  become_method: sudo
  when: 
    - '"telegraf" not in template'
    - not non_root_enabled | bool
    - 'remote_host is not defined or remote_host == "null"'
  tags: configuration

```

This task is failing and giving me this error:

```auto
{

  "module_stdout": "",

  "module_stderr": "Shared connection to 10.99.8.50 closed.\r\n",

  "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",

  "rc": 1,

  "ansible_facts": {

    "discovered_interpreter_python": "/usr/bin/python"

  },

  "_ansible_no_log": false,

  "changed": false

}

```

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/0/07b5a94415964fb542684ef5e89a5d63a56372e2.png)

Env details:  
1.) AWX: 17.1.0  
2.) Ansible: ansible 2.9.18  
config file = /etc/ansible/ansible.cfg  
configured module search path = [‘/var/lib/awx/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python3.6/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]  
3.) OS: Red Hat Enterprise Linux Server release 7.5 (Maipo)  
4.) Deployment type: Docker container i.e awx\_task, awx\_web, awx\_redis, awx\_postgres

What can be the reason ?

Thanks,  
Mohammed Husnain

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [May 29, 2024, 9:36am UTC](https://forum.ansible.com/t/ansible-task-failure-stating-shared-connection-closed-module-failure/5906/2 "2024-05-29T09:36:16Z")

</div>

Hi Mohammed,  
Do your tasks before “Check conf file stat” are using `become` and `become_method` too ?

If no, probably the Check conf file stat tasks try to become root but it fails.

Can you try your failing task with :

1. only `become: true`
2. `become: true` + `become_user: root`
3. `become: true` + `become_user: root` + `become_method: su`

Let us know the results of 3 scenarios !
