Ansible provisioning speedup - using mitogen?

Hi, I’m just wondering if anyone here has had much luck using Mitogen to speed up your Trellis Ansible provisioning?

Here is a blog post that talks about it:

I’m going to give it a proper try after I get some other basics working. (I had some mixed issues with it - looks like the latest release doesn’t support my version of ansible so I needed to install like pip install https://github.com/mitogen-hq/mitogen/archive/master.zip to get over that first hurdle).

2 Likes

:exploding_head: that looks really cool. I’ve never tried but it’s definitely worth a try.

From glancing at the differences, it doesn’t seem like they should affect Trellis much other than maybe that sudoers one :crossed_fingers:

1 Like

I just stumbled across this and was able to speed up provisioning of a remote server from 45 minutes to about 4 minutes! That’s incredible.

Steps:

  • pip install mitogen within virtual environment. As of time of writing, this will install mitogen 3.4.0
  • Mitogen 3.4.0 is not compatible with ansible-core > 2.13.13, so we force installation of that version: pip install --force-reinstall -v "ansible-core==2.13.13"
  • There is a warning that ansible is not compatible with that version of ansible-core. I ignored this warning.

Edit ansible.cfg and add two lines as explained here:

[defaults]
strategy_plugins = /home/user/example.com/trellis/.trellis/virtualenv/lib/python3.10/site-packages/ansible_mitogen/plugins/strategy/
strategy = mitogen_linear

The exact path will depend on your virtual env. Be sure to point to the directory for ansible_mitogen, not mitogen. (You can find the path through pip show mitogen within the virtual env.)

Then you can trellis provision <environment> and be amazed at the speed.

1 Like