diff options
| -rw-r--r-- | group_vars/all.yml | bin | 1660 -> 1605 bytes | |||
| -rw-r--r-- | host_vars/archlinux.local.yml | bin | 288 -> 358 bytes | |||
| -rw-r--r-- | roles/python/tasks/main.yml | 26 |
3 files changed, 25 insertions, 1 deletions
diff --git a/group_vars/all.yml b/group_vars/all.yml Binary files differindex 8f9ce50f..9260503e 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml diff --git a/host_vars/archlinux.local.yml b/host_vars/archlinux.local.yml Binary files differindex 66880995..a39b6160 100644 --- a/host_vars/archlinux.local.yml +++ b/host_vars/archlinux.local.yml diff --git a/roles/python/tasks/main.yml b/roles/python/tasks/main.yml index ea78bed0..d2dfc9a9 100644 --- a/roles/python/tasks/main.yml +++ b/roles/python/tasks/main.yml @@ -32,6 +32,30 @@ export PATH="$PATH:$HOME/.local/bin" fi +- name: "Get installed python versions" + ansible.builtin.command: + cmd: "pyenv versions --bare" + environment: + PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" + register: installed_python_versions + changed_when: false + failed_when: false + +- name: "Remove unwanted python versions" + vars: + major_minor: "{{ item | regex_replace('^([0-9]+\\.[0-9]+).*', '\\1') }}" + ansible.builtin.command: + cmd: "pyenv uninstall -f {{ item }}" + environment: + PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" + loop: "{{ installed_python_versions.stdout_lines | default([]) }}" + when: + - installed_python_versions.rc == 0 + - item is regex('^[0-9]+\.[0-9]+') + - item not in python_versions + - major_minor not in python_versions + changed_when: true + - name: "Install python versions" ansible.builtin.command: cmd: "pyenv install {{ item }}" @@ -39,7 +63,7 @@ creates: "{{ ansible_env.HOME }}/.pyenv/versions/{{ item }}*/bin/python" environment: PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" - with_items: "{{ python_versions | default([]) }}" + with_items: "{{ python_versions }}" - name: "Set global python version" ansible.builtin.command: |
