Ansible Md5 checksum

问题描述 投票:0回答:1

**当Md5结果匹配时,我一直在尝试安装新的操作系统,但我无法通过。我不断收到错误消息:“错误消息是:评估条件(md5_result.stdout [0] ==“” asdh3jk23h4343243434334“时出错。'dict对象'没有属性'stdout'\,请建议**

>  - block:
>           - name: verify MD5
>             ios_command:
>               provider: "{{ creds }}"             
>               commands: sh file bootflash:{{ki}} md5sum
>             register: md5_result
>           - name: Install OS 
>             check_mode: no
>             nxos_install_os:
>               provider: "{{ creds }}"
>               kickstart_image_file: "{{ki}}"
>               system_image_file: "{{si}}"
>               issu: desired
>             when: md5_result.stdout[0] == "asdh3jk23h4343243434334"

var的输出:md5_result

  "md5_result": {
    "changed": false,
    "failed": false,
    "stdout": [
        "asdh3jk23h43434343434343"
    ],
    "stdout_lines": [
        [
            "asdh3jk23h43434343434343"
        ]
    ]
}

}

ansible yaml md5 checksum cisco
1个回答
0
投票

我能够完成这项工作:

    - block:
      - name: verify MD5
        ios_command:
          provider: "{{ creds }}"
          commands: show file bootflash:{{bin}} md5sum
        register: md5_result
      - debug:
          var: md5_result.stdout[0]
   - block:
      - name: Install OS
        nxos_install_os:
          provider: "{{ creds }}"
          system_image_file: "{{bin}}"
          issu: no
          timeout: 500
        when: md5_result.stdout[0] == "asdh3jk23h43434343434343"
© www.soinside.com 2019 - 2024. All rights reserved.