Skip to content

Instantly share code, notes, and snippets.

@AnatomicJC
Last active February 19, 2023 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnatomicJC/d618d1938279f56b0bc3b5276fb0d167 to your computer and use it in GitHub Desktop.
Save AnatomicJC/d618d1938279f56b0bc3b5276fb0d167 to your computer and use it in GitHub Desktop.
Ansible 2.14.2 setup with mitogen

Create requirements.txt file:

ansible==7.2.0
ansible-lint==6.10.0
jmespath
dnspython
git+https://github.com/mitogen-hq/mitogen.git@a47b9f3631ba3c37bf0410c6a4960c3eec152454

Create ansible-setup.bash:

#!/usr/bin/env bash

set -euo pipefail

SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd -P)
cd "${SCRIPT_DIR}"

# ansible 7.2.0 is ansible-core 2.14.2
ANSIBLE_VERSION=7.2.0

sudo apt update
sudo apt install -y python3-venv

mkdir -p "${HOME}"/.ansible_venv
python3 -m venv "${HOME}"/.ansible_venv/ansible-"${ANSIBLE_VERSION}"
# shellcheck source=/dev/null
source "${HOME}"/.ansible_venv/ansible-"${ANSIBLE_VERSION}"/bin/activate
python3 -m pip install --use-pep517 --upgrade pip setuptools
python3 -m pip install --use-pep517 -r requirements.txt

# Mitogen
sed -i "s/^ANSIBLE_VERSION_MAX = (2, 13)/ANSIBLE_VERSION_MAX = (2, 14)/" $(python3 -c "import sys; print(sys.path.pop())")/ansible_mitogen/loaders.py

Install ansible:

bash ansible-setup.bash

Load ansible python virtualenv and enable mitogen:

. ~/ansible_venv/ansible-7.2.0/bin/activate
export ANSIBLE_STRATEGY_PLUGINS=$(python3 -c "import sys; print(sys.path.pop())")/ansible_mitogen/plugins/strategy
export ANSIBLE_STRATEGY=mitogen_linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment