Ansible Md5 校验和

Ansible Md5 checksum

** 我一直在尝试在 Md5 结果匹配时安装新的 OS,但我无法通过它。我不断收到错误消息:"The error was: error while evaluating conditional (md5_result.stdout[0] == ""asdh3jk23h4343243434334"。 'dict object'没有属性'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"
        ]
    ]
}

}

我能够完成这项工作:

    - 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"