- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 04:32 AM
we wrote ansible script to create 200 vlan pool in ACI APIC, but execution is too slow. it take more than one hour to finish the job! With postman it take 2 minutes to create 200 vlan pool. how can we improve ansible time execution?
Solved! Go to Solution.
- Labels:
-
APIC
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 04:51 AM
Yes this commonly seen as Postman is primarily designed for manual API testing and interaction and it's optimized for sending requests and handling responses efficiently where as Ansible is focused on infrastructure automation and configuration management. and whilst it can interact with APIs, it has additional layers of functionality, like task execution, dependency management, and error handling, which can add overhead... etc...
If you're currently creating each VLAN pool with a separate Ansible task, switch to using a loop method as this allows you to define the pool configurations once and iterate through them, reducing redundancy and API calls. The only way to speed this up is to use modules like async
or community.async
which allows parallel execution of tasks, potentially speeding things up. For example, using the asynchronous mode to create the VLAN pools with a timeout of 60 seconds and without polling.
- name: Create VLAN pools asynchronously
cisco.aci.aci_vlan_pool:
host: apic
username: admin
private_key: "{{ private_key }}"
pool: "{{ item.pool }}"
pool_allocation_mode: dynamic
description: "Production VLANs - Batch {{ item.batch }}"
state: present
loop: "{{ vlan_pools | groupby('pool') | list }}"
loop_control:
loop_var: item
async: 60
poll: 0
Hope this helps.
Connect with me https://bigevilbeard.github.io

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 04:51 AM
Yes this commonly seen as Postman is primarily designed for manual API testing and interaction and it's optimized for sending requests and handling responses efficiently where as Ansible is focused on infrastructure automation and configuration management. and whilst it can interact with APIs, it has additional layers of functionality, like task execution, dependency management, and error handling, which can add overhead... etc...
If you're currently creating each VLAN pool with a separate Ansible task, switch to using a loop method as this allows you to define the pool configurations once and iterate through them, reducing redundancy and API calls. The only way to speed this up is to use modules like async
or community.async
which allows parallel execution of tasks, potentially speeding things up. For example, using the asynchronous mode to create the VLAN pools with a timeout of 60 seconds and without polling.
- name: Create VLAN pools asynchronously
cisco.aci.aci_vlan_pool:
host: apic
username: admin
private_key: "{{ private_key }}"
pool: "{{ item.pool }}"
pool_allocation_mode: dynamic
description: "Production VLANs - Batch {{ item.batch }}"
state: present
loop: "{{ vlan_pools | groupby('pool') | list }}"
loop_control:
loop_var: item
async: 60
poll: 0
Hope this helps.
Connect with me https://bigevilbeard.github.io
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 05:42 AM
try to use cert auth with ACI
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/
