Ansible ios_command,stdout_lines为空且命令不执行

时间:2019-08-20 08:52:04

标签: ansible

Ansible版本:Ansible 2.7.10 塔3.4.3

我有以下任务用于将o文件复制到Cisco交换机:

- name: Copy IOS Image to 4500 Switch
  ios_command:
    commands: 
      - command: "copy ftp://{{user_ftp}}:{{pass_ftp}}@{{ network_server }}:/{{ path }}/{{ filename }} bootflash:"
        prompt: '[{{ filename }}]'
        answer: "\r"
  when: device_model == "WS-C4503-E" and current_version != new_version
  vars:
    ansible_command_timeout: 3600

您是否知道为什么没有错误但命令没有执行?

我使用相同的任务将文件复制到不同的设备型号,并且可以正常工作,但是仅对于Cisco 4500交换机而言,没有错误,但是文件没有被复制。

这是输出:

{
    "_ansible_parsed": true,
    "_ansible_no_log": false,
    "stdout": [
        ""
    ],
    "changed": false,
    "invocation": {
        "module_args": {
            "username": null,
            "authorize": null,
            "commands": [
                {
                    "answer": "\r",
                    "command": "copy ftp://user:pass@ip-server:/tftpboot/Catalyst4500/filetest.txt bootflash:",
                    "prompt": "[filetest.txt]"
                }
            ],
            "ssh_keyfile": null,
            "retries": 10,
            "auth_pass": null,
            "wait_for": null,
            "interval": 1,
            "host": null,
            "timeout": null,
            "provider": null,
            "password": null,
            "port": null,
            "match": "all"
        }
    },
    "stdout_lines": [
        [
            ""
        ]
    ]
}



stdout_lines中没有任何内容。当我在其他模型上尝试相同的任务时:

{
    "_ansible_parsed": true,
    "_ansible_no_log": false,
    "stdout": [
        "Destination filename [filetest.txt]? \nAccessing ftp://*:*@ip-server/tftpboot/ISR4000/filetest.txt...\nLoading tftpboot/ISR4000/filetest.txt \n[OK - 18/4096 bytes]\n\n18 bytes copied in 1.868 secs (10 bytes/sec)"
    ],
    "changed": false,
    "invocation": {
        "module_args": {
            "username": null,
            "authorize": null,
            "commands": [
                {
                    "answer": "\r",
                    "command": "copy ftp://user:pass@ip-server:/tftpboot/ISR4000/filetest.txt bootflash:",
                    "prompt": "[filetest.txt]"
                }
            ],
            "ssh_keyfile": null,
            "retries": 10,
            "auth_pass": null,
            "wait_for": null,
            "interval": 1,
            "host": null,
            "timeout": null,
            "provider": null,
            "password": null,
            "port": null,
            "match": "all"
        }
    },
    "stdout_lines": [
        [
            "Destination filename [filetest.txt]? ",
            "Accessing ftp://*:*@ip-server/tftpboot/ISR4000/filetest.txt...",
            "Loading tftpboot/ISR4000/filetest.txt ",
            "[OK - 18/4096 bytes]",
            "",
            "18 bytes copied in 1.868 secs (10 bytes/sec)"
        ]
    ]
}

0 个答案:

没有答案