Ansible task failure stating shared connection closed module failure

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

- 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:

{

  "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

}

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

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 !