0

**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"
        ]
    ]
}

}

MrKarma4u
  • 144
  • 2
  • 13
  • What is the output of `- debug: var=md5_result` when inserted right before that `- name: Install OS` task? – mdaniel Feb 28 '20 at 04:03
  • "md5_result": { "changed": false, "failed": false, "stdout": [ "asdh3jk23h43434343434343" ], "stdout_lines": [ [ "asdh3jk23h43434343434343" ] ] } } – MrKarma4u Mar 02 '20 at 18:33
  • Then please update your question to include the real error message, because that output and your claimed message don't square up; You also should include the output of `ansible --version` since it's further impossible to track down if you're using ansible 0.55 beta or something equally silly – mdaniel Mar 02 '20 at 22:06

1 Answers1

0

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"
MrKarma4u
  • 144
  • 2
  • 13