Last active
March 5, 2022 11:45
-
-
Save ScriptAutomate/89717aa00ed71f8069280972de6e0759 to your computer and use it in GitHub Desktop.
Configure pyenv with salt state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is tested/verified on Pop!_OS 20.04 and 20.10 | |
# Older versions tested on Parrot OS 4.1.0 | |
# This example state requires common:lookup:user value in a pillar file | |
{% set user_name = salt['pillar.get']('common:lookup:user') %} | |
# Prereqs recommended for building Python | |
## ref: https://github.com/pyenv/pyenv/wiki#suggested-build-environment | |
## Ubuntu/Debian/Mint (includes Pop!_OS, Kali, etc.) | |
pyenv-prereq-pkgs: | |
pkg.installed: | |
- pkgs: | |
- git | |
- make | |
- build-essential | |
- libssl-dev | |
- zlib1g-dev | |
- libbz2-dev | |
- libreadline-dev | |
- libsqlite3-dev | |
- wget | |
- curl | |
- llvm | |
- libncurses5-dev | |
- xz-utils | |
- tk-dev | |
- libxml2-dev | |
- libffi-dev | |
- liblzma-dev | |
- python-is-python3 | |
{% if grains['os'] == 'Ubuntu' or grains['os'] == 'Pop' %} | |
# Parrot OS runs into dependency errors with libxmlsec1-dev | |
# that don't seem resolvable at the moment. | |
# Parrot OS 4.1.0 - Home Edition | |
- libxmlsec1-dev | |
{% endif %} | |
# Clone latest version of git repo for pyenv | |
pyenv-repo: | |
git.latest: | |
- name: https://github.com/pyenv/pyenv.git | |
- target: /home/{{ user_name }}/.pyenv | |
- rev: master | |
pyenv-virtualenv-plugin-repo: | |
git.latest: | |
- name: https://github.com/pyenv/pyenv-virtualenv.git | |
- target: /home/{{ user_name }}/.pyenv/plugins/pyenv-virtualenv | |
- rev: master | |
pyenv-permissions: | |
file.directory: | |
- name: /home/{{ user_name }}/.pyenv | |
- user: {{ user_name }} | |
- group: {{ user_name }} | |
- recurse: | |
- user | |
- group | |
# ~/.bashrc config via the GitHub checkout directions, slightly modified | |
# https://github.com/pyenv/pyenv#basic-github-checkout | |
pyenv-bashrc: | |
file.append: | |
- name: /home/{{ user_name }}/.bashrc | |
- text: | | |
# Initializing pyenv | |
# Other pyenv info in ~/.profile | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PATH" | |
export PYENV_VIRTUALENV_DISABLE_PROMPT=1 | |
if shopt -q login_shell; then | |
eval "$(pyenv init --path)" | |
fi | |
eval "$(pyenv init -)" | |
eval "$(pyenv virtualenv-init -)" | |
# ~/.profile config via the GitHub checkout directions, slightly modified | |
# https://github.com/pyenv/pyenv#basic-github-checkout | |
pyenv-profile: | |
file.prepend: | |
- name: /home/{{ user_name }}/.profile | |
- text: | | |
# pyenv initialization | |
# At top of file; needs to be before sourcing ~/.bashrc | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init --path)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment