cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1105
Views
3
Helpful
5
Replies

ansible slow execution

mzouggagh
Level 1
Level 1

Hi,

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?

 

5 Replies 5

Torbjørn
Spotlight
Spotlight

Can you post your ansible playbook and ansible.cfg?

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

yes

for config file

#ansible --version
ansible [core 2.14.4]
config file = None

Not sure why the execution takes so long, it shouldn't take an hour to complete. Can you post the output when you run the playbook with -vvv ?

You can probably speed up your playbook using async to execute the task in parallel. See the attached file for what that could look like. I am unable to test it ATM, so it might not work - will debug it later if there are errors.

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

Thank you @Torbjørn 

adding async 60 and pool 0 to the script reduced time execution to about 4 minutes

the drawback of this method is the result display all tasks in changed state

 

Hey @mzouggagh there is a couple of way this can be sped up which i used in the past (this was with switches and routers)

  • Async mode. This will allow Ansible to run multiple tasks simultaneously, which can significantly improve performance, especially for large tasks, such as this one
  • Parallel mode. This is similar to async mode, but it will run tasks in parallel on multiple hosts. This can be even faster than async mode, but it does requires that you have multiple hosts available fyi
  • Caching. Ansible can cache the results of tasks, which can avoid having to re-execute the same task multiple times. This can be especially useful for tasks that are slow to execute

Also try using modules that are optimized for speed, did find some Ansible modules are optimized for speed, while others are not. Like for example, the aci_fabric module is optimized for speed, while the aci_vlan module is not. I think the reason for the diff in speed here is Postman is a single-threaded application, while Ansible is a multi-threaded application. 

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io