# Async with networking devices

**URL:** <https://forum.ansible.com/t/async-with-networking-devices/6155>\
**Category:** Get Help\
**Created:** [June 4, 2024, 1:30pm UTC](https://forum.ansible.com/t/async-with-networking-devices/6155 "2024-06-04T13:30:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsavich](https://avatars.discourse-cdn.com/v4/letter/n/d78d45/32.png) [@nsavich](https://forum.ansible.com/u/nsavich)\
**Post date:** [June 4, 2024, 1:30pm UTC](https://forum.ansible.com/t/async-with-networking-devices/6155/1 "2024-06-04T13:30:48Z")

</div>

I’m trying to understand how async interacts with networking devices such as Cisco switches. In my task below, I have async configured for two sets of commands that I want to run on specific models of switches. The problem therein lies with the amount of time it takes the first task to execute before proceeding to the next task. Which brought me to async.

Ideally, I would like both of the tasks to run simultaneously. And afterwards async\_status to verify that these tasks completed without error.

With async\_status set, should I delegate to localhost to check for the job\_id? Has anyone had success with this?

```auto
        - name: Upgrade switches using install add
          cisco.ios.ios_command:
            commands:
              - command: 'install add file flash:{{ models[ansible_net_model]["ios_binary"] }} activate commit'
                prompt: 'This operation may require a reload of the system. Do you want to proceed?'
                answer: 'y'
          async: 1800
          poll: 0
          when:
            - models[ansible_net_model]["ios_md5"] in md5_result.stdout[0]
            - ansible_net_model in ['C9200L-24P-4G', 'C9200L-48P-4G', 'C9300X-12Y']
          tags:
            - boot
          register: install_add_task

        - name: Upgrade switches using request platform
          cisco.ios.ios_command:
            commands:
              - command: 'request platform software package install switch all file flash:{{ models[ansible_net_model]["ios_binary"] }} new auto-copy'
              - command: 'reload'
                prompt: 'Proceed with reload?'
                answer: "\r"
          async: 1800
          poll: 0
          when:
            - models[ansible_net_model]["ios_md5"] in md5_result.stdout[0]
            - ansible_net_model in ['C9300-24U', 'C9300-48U', 'C9500-16X', 'WS-C3850-24P', 'WS-C3850-48P', 'WS-C3850-12S', 'WS-C3850-24XS', 'WS-C3850-24U', 'WS-C3850-48U']
          tags:
            - boot
          register: request_platform_task

        - name: Wait for Upgrade tasks to complete
          any_errors_fatal: true
          ansible.builtin.async_status:
            jid: "{{ item }}"
          register: async_result
          until: async_result.finished
          retries: 100
          delay: 1
          with_items:
            - install_add_task.ansible_job_id
            - request_platform_task.ansible_job_id

```

---

<div class="post-metadata">

**Author:** ![nsavich](https://avatars.discourse-cdn.com/v4/letter/n/d78d45/32.png) [@nsavich](https://forum.ansible.com/u/nsavich)\
**Post date:** [June 4, 2024, 1:32pm UTC](https://forum.ansible.com/t/async-with-networking-devices/6155/2 "2024-06-04T13:32:12Z")

</div>

This is an example of an error I get without delegating to localhost.

```auto
failed: [10.19.255.211] (item=install_add_task.ansible_job_id) => {"ansible_job_id": "install_add_task.ansible_job_id", "ansible_loop_var": "item", "attempts": 1, "changed": false, "finished": 1, "item": "install_add_task.ansible_job_id", "msg": "could not find job", "results_file": "/home/runner/.ansible_async/install_add_task.ansible_job_id", "started": 1, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [10.19.255.211] (item=request_platform_task.ansible_job_id) => {"ansible_job_id": "request_platform_task.ansible_job_id", "ansible_loop_var": "item", "attempts": 1, "changed": false, "finished": 1, "item": "request_platform_task.ansible_job_id", "msg": "could not find job", "results_file": "/home/runner/.ansible_async/request_platform_task.ansible_job_id", "started": 1, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

```
