Search code examples
ansibleyamlmd5checksumcisco

Ansible Md5 checksum


**I have been trying to Install the new OS when the Md5 result matches but I am unable to get pass that. I keep getting error: "The error was: error while evaluating conditional (md5_result.stdout[0] == ""asdh3jk23h4343243434334". 'dict object' has no attribute 'stdout'\ Please suggest **

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

The output of var: md5_result

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

}


Solution

  • I was able to make this work:

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