DEV Community

Discussion on: Speed up Ansible with Mitogen!

Collapse
 
eduardosufan profile image
Eduardo Zaqui Sufán

Hi Sergey, thanks for the tutorial. I'm trying to make it work but is not taken my ANSIBLE_STRATEGY_PLUGINS variable.

I have configure it in my playbooy as:

  • hosts: local .... strategy: mitogen_linear strategy_plugins: /usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy Here execution says "strategy_plugins" is not command valid...

And as a environment execution in my apy:

command = ['ANSIBLE_STRATEGY_PLUGINS=/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy', 'ANSIBLE_STRATEGY=mitogen_linear', 'ansible-playbook', '-ihosts', 'ansible_scripts/inventory.yml']
process = subprocess.Popen(command, stdout=subprocess.PIPE)

Here is not finding directory
FileNotFoundError: [Errno 2] No such file or directory: 'ANSIBLE_STRATEGY_PLUGINS=/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy': 'ANSIBLE_STRATEGY_PLUGINS=/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy'

I'm using ansible 2.7.10
And python 3.6
Do you know how I can make it work?

Collapse
 
sshnaidm profile image
Sergey

Hi, Eduardo
firstly worth to check if path exists:


ls /usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy

you don't need specify 'strategy_plugins' in playbook, it's only for configuration file ansible.cfg, see my example in the article
is the path exists, just export it:


export ANSIBLE_STRATEGY_PLUGINS=/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy

and then run your playbook

Collapse
 
eduardosufan profile image
Eduardo Zaqui Sufán • Edited

Ok, now I see mitogen strategy working. But execution measurement time is the same with and without mitogen in my case (about 30min execution).
Do you know in which cases time execution will be very similar between strategies?

PD: right now I'm deploying just 1 host, a college says to me maybe I can find improvements with 2 or more hosts.

Thread Thread
 
sshnaidm profile image
Sergey

Yes, if ansible is not your bottleneck and you have much more long tasks, you can't see the improvement really, that's what I'm writing in the article in last example.