Cisco IOS md5检查ansible模块失败

时间:2019-01-14 15:36:19

标签: ansible cisco-ios

运行ansible 2.6

当我尝试运行命令时发生此错误:

verify /md5 flash:/{ios_file}

这是命令的输出:

TASK [IOS - MD5 CHECK - PASS1] **************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: timeout trying to send command: verify /md5 c2960x-universalk9-mz.152-2.E8.bin
fatal: [pdctestisesw7]: FAILED! => changed=false 
  module_stderr: |-
    Traceback (most recent call last):
      File "/tmp/ansible_cr7Tgd/ansible_module_ios_command.py", line 247, in <module>
        main()
      File "/tmp/ansible_cr7Tgd/ansible_module_ios_command.py", line 217, in main
        responses = run_commands(module, commands)
      File "/tmp/ansible_cr7Tgd/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py", line 148, in run_commands
      File "/tmp/ansible_cr7Tgd/ansible_modlib.zip/ansible/module_utils/connection.py", line 174, in __rpc__
    ansible.module_utils.connection.ConnectionError: timeout trying to send command: verify /md5 c2960x-universalk9-mz.152-2.E8.bin
  module_stdout: ''
  msg: MODULE FAILURE
  rc: 1
        to retry, use: --limit @/export/home/e130885/playbooks/ios-switch-upgrade/upgrade_ios_switch_v1.retry

这是正在执行的任务:

  - name: IOS - MD5 CHECK - PASS1
    ios_command:
      commands:
        - command: "verify /md5 {{ compliant_ios_file }}"
    register: md5_response
    vars:
      ansible_command_timeout: 3000
    when: 'compliant_ios_file in dir_response.stdout[0]'

这似乎只发生在执行时间超过一秒的命令上。

1 个答案:

答案 0 :(得分:0)

有多种方法可以实现,以下对我来说很好用。超时值因路由器类型而异。

>   - name: VERIFY_IMAGE
>     ios_command:
>         commands:
>         - "verify /md5 flash:c800-universalk9-mz.SPA.154-3.M10.bin"
>         wait_for:
>         - result[0] contains "a8216179d49e598579e21b7e5abc9046"
>         retries: 1
>     vars:
>         ansible_command_timeout: 120