First, switch to the directory where your ansible plays reside in and enable the timer callback plugin:
[archy@ansible02 /var/ansible]$ echo 'callback_whitelist = timer' >> ansible.cfg
This will summarize what tasks took a long time to execute. If there's nothing obvious, you can increase the forks. By default, it's set to '5' in the /etc/ansible/ansible.cfg
[archy@ansible02 /var/ansible]$ echo 'forks = 50' >> ansible.cfg
Run your playbook again and check the timings. The 'forks' parameter is only limited by cpu and network throughput ... so this might require some tweaking for your specific environment. Using only the 'forks' parameter, the execution runtime of the aforementioned play dropped by -15 minutes.
The last performance tweak you could try is changing the strategy to 'free' instead of linear which will make every host go through the play as fast as it can without waiting for the last host to finish on each task.
[archy@ansible02 /var/ansible]$ echo 'strategy = free' >> ansible.cfg
Note that this will make the output scrambled as each will perform a different task at a different time. If that's not a concern however, I was able to reduce the runtime again by -5 Minutes so in total the average execution time was down ~20 Minutes which I think is decent considering that these were only 2 parameters that were changed.
Another thing to consider is using 'gathering = smart' where fact gathering will only be run once at the start of the play.
[archy@ansible02 /var/ansible]$ echo 'gathering = smart' >> ansible.cfg
I've not tested if that shaves off another few minutes but depending on the amount of times facts are gathered and the amount of hosts, this might decrease runtime even more.
Feel free to comment and / or suggest a topic.
Comments
Post a Comment