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

**URL:** <https://forum.ansible.com/t/need-assistance-to-run-tasks-module-on-several-switch-simultaneously-my-script-currently-checks-1-device-at-a-time/34892>\
**Category:** Ansible Project\
**Created:** [March 31, 2021, 12:38am UTC](https://forum.ansible.com/t/need-assistance-to-run-tasks-module-on-several-switch-simultaneously-my-script-currently-checks-1-device-at-a-time/34892 "2021-03-31T00:38:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [March 31, 2021, 12:38am UTC](https://forum.ansible.com/t/need-assistance-to-run-tasks-module-on-several-switch-simultaneously-my-script-currently-checks-1-device-at-a-time/34892/1 "2021-03-31T00:38:09Z")

</div>

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]”

---

<div class="post-metadata">

**Author:** ![Teofil\_Mihance](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@Teofil\_Mihance](https://forum.ansible.com/u/Teofil_Mihance)\
**Post date:** [March 31, 2021, 9:01am UTC](https://forum.ansible.com/t/need-assistance-to-run-tasks-module-on-several-switch-simultaneously-my-script-currently-checks-1-device-at-a-time/34892/2 "2021-03-31T09:01:35Z")

</div>

Hi Vikram,  
Find [here](https://github.com/teofilmihance/ios_switch_update.git) an ansible role that includes among others a MD5 checksum task, [file\_check.yml](https://github.com/teofilmihance/ios_switch_update/blob/main/roles/switch_update/tasks/file_check.yml) and [checksum.py](https://github.com/teofilmihance/ios_switch_update/blob/main/roles/switch_update/tasks/checksum.py)  
It is a draft but is working fine.  
Best regards  
Teo
