keep getting error : "module_stderr": "Shared connection to host closed

any idea why?

No.

Give us more context, and we might have a clue.

Antony.

failed: [xxxxxxxx] (item={‘search’: ‘#image: graylog/graylog:4.3.2’, ‘add’: ‘image: graylog/graylog:4.3.3’}) => {
“ansible_loop_var”: “item”,
“changed”: false,
“item”: {
“add”: “image: graylog/graylog:4.3.3”,
“search”: “#image: graylog/graylog:4.3.2”
},
“module_stderr”: “Shared connection to xxxxx closed.\r\n”,
“module_stdout”: “\r\nTraceback (most recent call last):\r\n File "/home/twong/.ansible/tmp/ansible-tmp-1657826370.868146-3737-103625139036728/AnsiballZ_lineinfile.py", line 102, in \r\n _ansiballz_main()\r\n File "/home/twong/.ansible/tmp/ansible-tmp-1657826370.868146-3737-103625139036728/AnsiballZ_lineinfile.py", line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File "/home/twong/.ansible/tmp/ansible-tmp-1657826370.868146-3737-103625139036728/AnsiballZ_lineinfile.py", line 40, in invoke_module\r\n runpy.run_module(mod_name=‘ansible.modules.lineinfile’, init_globals=None, run_name=‘main’, alter_sys=True)\r\n File "/usr/lib64/python2.7/runpy.py", line 176, in run_module\r\n fname, loader, pkg_name)\r\n File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code\r\n mod_name, mod_fname, mod_loader, pkg_name)\r\n File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code\r\n exec code in run_globals\r\n File "/tmp/ansible_lineinfile_payload_oqguHr/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py", line 577, in \r\n File "/tmp/ansible_lineinfile_payload_oqguHr/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py", line 568, in main\r\n File "/tmp/ansible_lineinfile_payload_oqguHr/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py", line 342, in present\r\n File "/usr/lib64/python2.7/re.py", line 266, in _expand\r\n return sre_parse.expand_template(template, match)\r\n File "/usr/lib64/python2.7/sre_parse.py", line 800, in expand_template\r\n raise error, "unmatched group"\r\nsre_constants.error: unmatched group\r\n”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,

however this worked though

  • name: comment line
    lineinfile:
    backup: no
    backrefs: yes
    state: present
    path: “{{ file_path }}”
    regexp: ‘^(\s*)[#]?{{ item.search }}(: )*’
    line: ‘\1{{ item.replace }}’
    with_items:
  • { search: “{{ line.line_to_replace }}”, replace: “{{ line.replace_with }}” }

i think its because the destination machine dont have python3