1

使用 fetch 模块我得到一个模块错误。当我运行剧本时,-vvvv我得到以下调试输出,

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.

紧随其后的是

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
}

我的主机的 ssh_config 文件会导致 fetch 模块出现此错误吗?这刚刚开始发生并且之前已经工作过,我可以成功地 ping 我的主机。

这是从我的剧本中运行的实际任务。

- 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 }}'
4

1 回答 1

0

在您的ansible.cfg中,添加:

[ssh_connection]
ssh_args =

这将删除-o ControlMaster=auto -o ControlPersist=60s我认为导致问题的原因。

ansible_connection=netconf当您在连接到网络设备时忘记添加时,我还发现这是一个问题。在这种情况下,您将不需要上述修复。

于 2021-03-19T09:47:34.400 回答