aboutsummaryrefslogtreecommitdiffstats
path: root/roles/pyenv/tasks/main.yaml
blob: 7a20c78ca33964a8a660be92619cdfe9a164c03a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
- name: Install build requirements
  become: yes

  dnf:
    name: "{{ item.key }}"
    state: "{{ item.value.state | default('present') }}"

  with_dict: "{{dnf}}"
  vars:
    dnf:
      make:
      gcc:
      zlib-devel:
      bzip2:
      bzip2-devel:
      readline-devel:
      sqlite:
      sqlite-devel:
      openssl-devel:
      tk-devel:
      libffi-devel:
      xz-devel:

- name: Download
  ansible.builtin.git:
    repo: https://github.com/pyenv/pyenv.git
    dest: "{{ lookup('env', 'HOME') }}/.pyenv"
    version: v2.3.4

- name: "Ensure shell startup file sets up correct environment"
  lineinfile:
    path: "{{ shell_startup_file_path }}"
    line: "{{ item.value.line }}"
    state: present

  with_dict: "{{lines}}"
  vars:
    # Assumption: This will only work for certain shells (like zsh, bash, etc.)
    lines:
      pyenv_root:
        line: export PYENV_ROOT="$HOME/.pyenv"
      export_pyenv_bin:
        line: command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
      pyenv_init:
        line: eval "$(pyenv init -)"