Skip to content
This repository was archived by the owner on Mar 30, 2025. It is now read-only.

Commit 9e1ea7b

Browse files
committed
Fix pipx install for Debian 12
1 parent 2b96f3f commit 9e1ea7b

File tree

3 files changed

+84
-72
lines changed

3 files changed

+84
-72
lines changed

meta/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ galaxy_info:
2929
- pyenv
3030
- pipx
3131
- precommit
32+
- tox
3233
- workstation
3334

3435
dependencies:

tasks/custom_facts.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- name: Set command path based on distribution
3+
ansible.builtin.set_fact:
4+
pipx_path: "{{ '/usr/bin' if ansible_distribution_release == 'bookworm' else ansible_env.HOME + '/.local/bin' }}"

tasks/main.yml

Lines changed: 79 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
- name: Load custom facts
3+
ansible.builtin.import_tasks: custom_facts.yml
4+
25
- name: Install pyenv
36
ansible.builtin.import_role:
47
name: staticdev.pyenv
@@ -17,87 +20,91 @@
1720
- python3-venv # needed for nox
1821

1922
- name: Check if pipx is installed
20-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx --version"
23+
ansible.builtin.command: "{{ pipx_path }}/pipx --version"
2124
register: pipx_version_cmd
2225
changed_when: false
2326
ignore_errors: true
2427

25-
- name: Install pipx
28+
- name: Install pipx on Debian Bookworm
29+
ansible.builtin.package:
30+
name: pipx
31+
when: pipx_version_cmd is failed and ansible_distribution_release == 'bookworm'
32+
33+
- name: Install pipx on non-Bookworm OS
2634
ansible.builtin.pip:
2735
name: pipx
2836
extra_args: --user
29-
when: pipx_version_cmd is failed
37+
when: pipx_version_cmd is failed and ansible_distribution_release != 'bookworm'
38+
# - name: Check if pre-commit is installed
39+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pre-commit --version"
40+
# register: pre_commit_check
41+
# changed_when: false
42+
# ignore_errors: true
3043

31-
- name: Check if pre-commit is installed
32-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pre-commit --version"
33-
register: pre_commit_check
34-
changed_when: false
35-
ignore_errors: true
44+
# - name: Install pre-commit
45+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install pre-commit"
46+
# register: output
47+
# changed_when: "output.rc == 0"
48+
# when: pre_commit_check is failed
3649

37-
- name: Install pre-commit
38-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install pre-commit"
39-
register: output
40-
changed_when: "output.rc == 0"
41-
when: pre_commit_check is failed
42-
43-
- name: Check if cookiecutter is installed
44-
ansible.builtin.stat:
45-
path: "{{ ansible_env.HOME }}/.local/pipx/venvs/cookiecutter"
46-
register: cookiecutter_folder_check
47-
48-
- name: Install cookiecutter
49-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install cookiecutter"
50-
register: output
51-
changed_when: "output.rc == 0"
52-
when: cookiecutter_folder_check is failed
53-
54-
- name: Check if poetry is installed
55-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/poetry"
56-
register: poetry_cmd
57-
changed_when: false
58-
ignore_errors: true
50+
# - name: Check if cookiecutter is installed
51+
# ansible.builtin.stat:
52+
# path: "{{ ansible_env.HOME }}/.local/pipx/venvs/cookiecutter"
53+
# register: cookiecutter_folder_check
5954

60-
- name: Download poetry installer
61-
ansible.builtin.get_url:
62-
url: https://install.python-poetry.org
63-
dest: "{{ ansible_env.HOME }}/install-poetry.py"
64-
mode: "0400"
65-
timeout: 20
66-
when: poetry_cmd is failed
67-
notify: Delete poetry installer
68-
69-
- name: Install poetry
70-
ansible.builtin.command: "python3 {{ ansible_env.HOME }}/install-poetry.py"
71-
register: output
72-
changed_when: "output.rc == 0"
73-
when: poetry_cmd is failed
74-
75-
- name: Check if nox is installed
76-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/nox --version"
77-
register: nox_version_cmd
78-
changed_when: false
79-
ignore_errors: true
55+
# - name: Install cookiecutter
56+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install cookiecutter"
57+
# register: output
58+
# changed_when: "output.rc == 0"
59+
# when: cookiecutter_folder_check is failed
8060

81-
- name: Install nox
82-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install nox"
83-
register: output
84-
changed_when: "output.rc == 0"
85-
when: nox_version_cmd is failed
86-
87-
- name: Install nox-poetry
88-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx inject nox nox-poetry"
89-
register: output
90-
changed_when: "output.rc == 0"
91-
when: nox_version_cmd is failed
92-
93-
- name: Check if tox is installed
94-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/tox --version"
95-
register: tox_version_cmd
96-
changed_when: false
97-
ignore_errors: true
61+
# - name: Check if poetry is installed
62+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/poetry"
63+
# register: poetry_cmd
64+
# changed_when: false
65+
# ignore_errors: true
66+
67+
# - name: Download poetry installer
68+
# ansible.builtin.get_url:
69+
# url: https://install.python-poetry.org
70+
# dest: "{{ ansible_env.HOME }}/install-poetry.py"
71+
# mode: "0400"
72+
# timeout: 20
73+
# when: poetry_cmd is failed
74+
# notify: Delete poetry installer
75+
76+
# - name: Install poetry
77+
# ansible.builtin.command: "python3 {{ ansible_env.HOME }}/install-poetry.py"
78+
# register: output
79+
# changed_when: "output.rc == 0"
80+
# when: poetry_cmd is failed
81+
82+
# - name: Check if nox is installed
83+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/nox --version"
84+
# register: nox_version_cmd
85+
# changed_when: false
86+
# ignore_errors: true
87+
88+
# - name: Install nox
89+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install nox"
90+
# register: output
91+
# changed_when: "output.rc == 0"
92+
# when: nox_version_cmd is failed
93+
94+
# - name: Install nox-poetry
95+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx inject nox nox-poetry"
96+
# register: output
97+
# changed_when: "output.rc == 0"
98+
# when: nox_version_cmd is failed
99+
100+
# - name: Check if tox is installed
101+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/tox --version"
102+
# register: tox_version_cmd
103+
# changed_when: false
104+
# ignore_errors: true
98105

99-
- name: Install tox
100-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install tox"
101-
register: output
102-
changed_when: "output.rc == 0"
103-
when: tox_version_cmd is failed
106+
# - name: Install tox
107+
# ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install tox"
108+
# register: output
109+
# changed_when: "output.rc == 0"
110+
# when: tox_version_cmd is failed

0 commit comments

Comments
 (0)