Антон Маркелов

Автоматизирую, поддерживаю, починяю примус

 » Home
 » Обо мне
 » CV Rus
 » Resume Eng (PDF)
 » Github
 » XML Feed

Yet another 'How to speed up Ansible' tips

02 Jan 2019 » ansible

SSH settings


ssh_args = -o PreferredAuthentications=publickey -o ControlMaster=auto -o ControlPersist=60s
pipelining = True

PreferredAuthentications helps to initiate the connection faster (without trying rare gssapi-with-mic,gssapi-keyex,hostbased methods).

ControlMaster and ControlPersist allows multiplexing existing connections to the server.

Useful links: https://serverfault.com/questions/929222/ansible-where-do-preferredauthentications-ssh-settings-come-from

Facts caching


gathering = smart

These options enable fact caching for 1 day and tell Ansible not gather facts in they already presented in the cache.

Useful links:


The most important part, in my opinion. There is no universal way, but I have some recomemndations:

  • Try to make tasks idempotent as possible. No need to do a useless job;
  • Delete duplicating tasks. For example, you’re may try to enable the firewall every time when you’re installing something. These tasks may be idempotent, but they still consume execution time;
  • Use something like Ara to visualize the playbook execution. Ara provides a good web interface and allows to sort tasks for execution time.

Useful links: https://github.com/openstack/ara