Need assistance to run tasks/module on several switch simultaneously (my script currently checks 1 device at a time)

11 views
Skip to first unread message

Vikram S

unread,
Mar 30, 2021, 8:38:09 PM3/30/21
to Ansible Project

Below is the script i have written to perform MD5 verification for stacked switch 2. Problem with this script is that iam saving output of MD5 verification command to a custom varriable called 'md5_flash2' using register and then checking if correct md5 value is present there.

Since iam using register, so only the output of last device will get saved (and over-write previous data) in this custom variable. So iam forced to check MD5 verification for 1 device at a time. Is there any alternate way to write script to do do MD5 verification (and other tasks) simultaneously for several devices?

 - name: DO MD5 VERIFICATION FOR FLASH 2 AND END PLAYBOOK IF IT FAILS

      block:

      - ios_command:

          commands: "verify /md5 flash2:/c2960x-universalk9-mz.152-7.E3/c2960x-universalk9-mz.152-7.E3.bin"

        vars:

          ansible_command_timeout: 360


        register: md5_flash2


      - debug:

          msg: MD5 VERIFICATION IS SUCCESSFUL FOR FLASH 2

        when: "'f148fc860a1d4d08532bc616724e632d' in md5_flash2.stdout[0]"


      - meta: end_host

        when: "'f148fc860a1d4d08532bc616724e632d' not in md5_flash2.stdout[0]"


      when:

        - "'Switch 02' in show_version.stdout[0]"

Teofil Mihance

unread,
Mar 31, 2021, 5:01:58 AM3/31/21
to ansible...@googlegroups.com
Hi Vikram, 
Find here an ansible role that includes among others a MD5 checksum task, file_check.yml and checksum.py
It is a draft but is working fine.
Best regards
Teo

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7d337e4d-7e6f-461c-a975-45447925e9a5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages