This Ansible role will install Python 3 and the pip
and virtualenv
utilities. The new version of Python is installed independently of the existing
system Python installation.
Although the pip
and virtualenv
command-line tools will be installed,
the recommended way to invoke them is as modules to ensure that the expected
version is used:
$ python3.6 -m pip install <package>
$ python3.6 -m venv <dir>
By default, Python is installed from packages. If the python3_pyenv
variable is set, pyenv will be installed and then used to install the
requested Python version, from source if necessary. The role will not
activate the new Python; see the pyenv documentation for ways to do this.
The role currently assumes that the user's login shell is bash
and modifies
startup files accordingly.
This role is also available on Ansible Galaxy.
python3_command
: Python command namepython3_bashrc
: login file to modify; defaults tobash_profile
python3_local
: local binary directory; system-dependentpython3_pyenv
: Python version to install using pyenv
- hosts: all
roles:
- name: python3
python3_pyenv: "3.6.4"