1

Using the fetch module I get a module error. When I run the playbook with -vvvv I get the following debug output,

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 45.00.00.00 is address
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 21668
debug3: mux_client_request_session: session request sent
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 137
Shared connection to 45.00.00.00 closed.

This is followed by

SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/home/maximum/.ansible/cp/1d97f3b2a1 45.00.00.00 '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1605874050.2884061-236476337621921/ > /dev/null 2>&1 && sleep 0'"'"''
<45.63.35.46> (0, b'', b'OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 45.00.00.00 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 21668\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
failed: [host1] (item={'path': '/home/domain/backup/archive/archive_2020-11-20.tar.gz', 'mode': '0644', 'isdir': False, 'ischr': False, 'isblk': False, 'isreg': True, 'isfifo': False, 'islnk': False, 'issock': False, 'uid': 0, 'gid': 0, 'size': 101263360, 'inode': 657061, 'dev': 64513, 'nlink': 1, 'atime': 1605858974.1760325, 'mtime': 1605858946.852478, 'ctime': 1605858946.852478, 'gr_name': 'root', 'pw_name': 'root', 'wusr': True, 'rusr': True, 'xusr': False, 'wgrp': False, 'rgrp': True, 'xgrp': False, 'woth': False, 'roth': True, 'xoth': False, 'isuid': False, 'isgid': False}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "atime": 1605858974.1760325,
        "ctime": 1605858946.852478,
        "dev": 64513,
        "gid": 0,
        "gr_name": "root",
        "inode": 657061,
        "isblk": false,
        "ischr": false,
        "isdir": false,
        "isfifo": false,
        "isgid": false,
        "islnk": false,
        "isreg": true,
        "issock": false,
        "isuid": false,
        "mode": "0644",
        "mtime": 1605858946.852478,
        "nlink": 1,
        "path": "/home/domain/backup/archive/archive_2020-11-20.tar.gz",
        "pw_name": "root",
        "rgrp": true,
        "roth": true,
        "rusr": true,
        "size": 101263360,
        "uid": 0,
        "wgrp": false,
        "woth": false,
        "wusr": true,
        "xgrp": false,
        "xoth": false,
        "xusr": false
    },
    "module_stderr": "OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 45.00.00.00 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: 
mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 21668\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 137\r\nShared connection to 45.00.00.00 closed.\r\n",
    "module_stdout": "Killed\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 137
}

What about my host's ssh_config file is causing this error with the fetch module? This just started happening and had worked before and I can successfully ping my hosts.

Here is the actual task that is being run from my playbook.

- name: Find and register {{ domain_name }} archive
  find:
    paths: /home/{{ domain_name }}/backup/archive/
    file_type: file
    patterns: "*.tar.gz"
  register: tar_file

- debug:
    var: tar_file

- name: Fetch {{ domain_name }} archive for offsite backup
  fetch:
    src: '{{ item.path }}'
    dest: '{{ store_path }}'
    fail_on_missing: yes
  with_items: '{{ tar_file.files }}'
Gee_k
  • 71
  • 2
  • 12
  • I marked line 19 in my ssh_config. Fetch still won't work as it now seem to think I'm an invalid attacker? I have ssh keys set up and all other tasks work. Output from ` systemctl status ssh ` ` Nov 22 01:42:32 server sshd[12626]: Invalid user mailman from 171.000.251.00 port 38924 Nov 22 01:42:37 server sshd[12626]: Connection closed by invalid user mailman 171.000.251.00 port 38924 [preauth] ` – Gee_k Nov 22 '20 at 01:54
  • Did you ever resolve this issue? – tread Mar 16 '21 at 15:19
  • Not quite. I believe the file I was trying to fetch was too large and that was the reason I was running into problems. I minimized the file size as much as I could and it started working. – Gee_k Mar 19 '21 at 09:39

1 Answers1

2

In your ansible.cfg, add:

[ssh_connection]
ssh_args =

This will remove the -o ControlMaster=auto -o ControlPersist=60s which I think is causing the issue.

I have also found this is an issue when you forget to add ansible_connection=netconf when connecting to network devices. In which case you won't need the above fix.

tread
  • 10,133
  • 17
  • 95
  • 170