Installs and configures Pyenv with given plugins and Python versions on RHEL or Debian/Ubuntu servers.
None.
Available variables are listed below, along with default values (refer to defaults/main and vars directories).
pyenv_global: false
pyenv_git_ref: master
pyenv_owner: "{{ ansible_user_id }}"
pyenv_group: pyenv
pyenv_path: "{{ '/opt/pyenv' if pyenv_global else ansible_user_dir + '/.pyenv' }}"
pyenv_config_path: "{{ '/etc/pyenv' if pyenv_global else ansible_user_dir + '/.dotfiles' }}"
pyenv_init_options: "{{ '--no-rehash' if not pyenv_global }}"
shell_init_paths: "{{ shell_init.global if pyenv_global else shell_init.local }}"
These are variables that control entire Pyenv installation process. Key one is
pyenv_global
which by deafult determines:
pyenv_path
- Pyenv installation path (system-wide/local).pyenv_config_path
- Pyenv configuration script path.pyenv_init_options
- flags forpyenv init
command added to Pyenv configuration script.shell_init_paths
- list of user's shell initialization files that sourcespyenv_config_path
file.
For the time being only bash
, zsh
and fish
shells are detected
automatically. These variables along with Pyenv git ref pyenv_git_ref
are
fully customizable according to target server's needs.
pyenv_owner
and pyenv_group
variables are especially critical for
system-wide installation to set proper permissions so that every user can use
Pyenv freely.
pyenv_autocompletion: true
pyenv_default_python: 3.11.2
pyenv_python_versions:
- 3.11.2
Above variables configures Pyenv after it is installed:
pyenv_autocompletion
- enables Pyenv commands autocompletion for user's shell.pyenv_default_python
- Python version to be set as a default interpreter.pyenv_python_versions
- list of Python versions, supported by given version of Pyenv, to be installed on the server.
pyenv_plugins:
- name: pyenv-virtualenv
repo: https://github.com/pyenv/pyenv-virtualenv.git
- name: pyenv-update
repo: https://github.com/pyenv/pyenv-update.git
pyenv_virtualenvs: {}
pyenv_update: false
Above variables allows installation of Pyenv plugins and configures them:
pyenv_plugins
- list of Pyenv plugins to be installed on the server. Bothname
andrepo
have to be provided for each plugin,version
is optional and indicates revision of a plugin repository.pyenv_virtualenvs
- list of Pyenv virtualenvs to be created on the server. Bothname
andversion
frompyenv_python_versions
have to be provided.pyenv_update
- updates of Pyenv and its plugins to the latest version.
None.
- hosts: all
roles:
- role: kmezynski.pyenv
pyenv_global: true
pyenv_path: /usr/local/share
pyenv_default_python: false
pyenv_python_versions:
- 3.11.2
- 3.10.9
This role is distributed under the terms of MIT license.
This role was created in 2023 by Kamil Mężyński.