The easiest way to run /usr/bin/ansible under Python 3 is to install it with the Python3 version of pip. This will make the default /usr/bin/ansible run with Python3: $ pip3 install ansible $ ansible --version | grep "python version" python version = 3 .6.2 ( default, Sep 22 2017, 08 :28:09) [ GCC 7 .2.1 20170915 ( Red Hat 7 .2.1-2 )] If you ...
If you have Ansible 2.9 or older installed or Ansible 3, see Upgrading Ansible with pip. Once pip is installed, you can install Ansible: $ python -m pip install ...
This works because only the Python 2 binary is called python (Python 3's interpreter is called python3). We save this tasks's result using Ansible's register directive. We use this result to judge whether Python's installation is necessary in the next task. How we install Python depends on whether our server runs CentOS or Ubuntu.
16.03.2021 · Now let's install Ansible. If you are running WSL2, this will take about 1 minute. But if you are running WSL1, this takes about 45 minutes*. Start over and install WSL2. $ python3 -m pip install ansible. Confirm your Ansible version. $ ansible --version