added pyenv role
This commit is contained in:
59
roles/avanov.pyenv/tasks/install.yml
Normal file
59
roles/avanov.pyenv/tasks/install.yml
Normal file
@ -0,0 +1,59 @@
|
||||
---
|
||||
- name: Install PyEnv
|
||||
git:
|
||||
repo: https://github.com/pyenv/pyenv.git
|
||||
dest: "{{ pyenv_path }}"
|
||||
update: "{{ pyenv_update_git_install }}"
|
||||
|
||||
- name: Install PyEnv-virtualenv plugin
|
||||
git:
|
||||
repo: https://github.com/yyuu/pyenv-virtualenv.git
|
||||
dest: "{{ pyenv_path }}/plugins/pyenv-virtualenv"
|
||||
update: "{{ pyenv_update_git_install }}"
|
||||
|
||||
- name: Install PyEnv-update plugin
|
||||
git:
|
||||
repo: https://github.com/pyenv/pyenv-update.git
|
||||
dest: "{{ pyenv_path }}/plugins/pyenv-update"
|
||||
update: "{{ pyenv_update_git_install }}"
|
||||
when: pyenv_update
|
||||
|
||||
- name: Install .pyenvrc
|
||||
template:
|
||||
src: ".pyenvrc.j2"
|
||||
dest: "{{ pyenv_path }}/.pyenvrc"
|
||||
owner: "{{ pyenv_owner }}"
|
||||
mode: "0644"
|
||||
|
||||
- name: "Load pyenv env variables in {{ pyenv_setting_path }}"
|
||||
lineinfile: dest="{{ pyenv_setting_path }}"
|
||||
regexp="\.pyenvrc$"
|
||||
line="source {{ pyenv_path }}/.pyenvrc"
|
||||
state=present
|
||||
create=yes
|
||||
|
||||
- name: "Add pyenv autocomplete in {{ pyenv_setting_path }}"
|
||||
lineinfile: dest="{{ pyenv_setting_path }}"
|
||||
regexp="pyenv\.bash$"
|
||||
line="source {{ pyenv_path }}/completions/pyenv.bash"
|
||||
state=present
|
||||
when: pyenv_enable_autocompletion
|
||||
|
||||
- name: Update Pyenv interpreter list
|
||||
shell: . {{ pyenv_path }}/.pyenvrc && pyenv update
|
||||
when: pyenv_update
|
||||
|
||||
- name: Install Python interpreters "{{ pyenv_python_versions }}"
|
||||
shell: . {{ pyenv_path }}/.pyenvrc && env PYTHON_CONFIGURE_OPTS="{{ pyenv_python_configure_opts }}" pyenv install {{ item }}
|
||||
creates="{{ pyenv_path }}/versions/{{ item }}/bin/python"
|
||||
with_items: "{{ pyenv_python_versions }}"
|
||||
|
||||
- name: Create virtual environments
|
||||
shell: . {{ pyenv_path }}/.pyenvrc && pyenv virtualenv {{ item.py_version }} {{ item.venv_name }}
|
||||
creates="{{ pyenv_path }}/versions/{{ item.venv_name }}/bin/python"
|
||||
with_items: "{{ pyenv_virtualenvs }}"
|
||||
|
||||
- name: Set pyenv global
|
||||
shell: . {{ pyenv_path }}/.pyenvrc && pyenv global {{ pyenv_global }} && pyenv rehash
|
||||
when: pyenv_global is defined
|
||||
|
Reference in New Issue
Block a user