feat: add pipx task management to Ansible configuration

This commit is contained in:
Menno van Leeuwen 2025-01-21 00:01:21 +01:00
parent 4024c2be7e
commit c7b27b6432
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
2 changed files with 29 additions and 1 deletions

View File

@ -1,4 +1,5 @@
- hosts: all
- name: Configure all hosts
hosts: all
gather_facts: true
tasks:
@ -65,3 +66,6 @@
- name: Include flatpaks tasks
ansible.builtin.import_tasks: tasks/flatpaks.yml
when: hostname in ['mennos-laptop', 'mennos-desktop']
- name: Include pipx tasks
ansible.builtin.import_tasks: tasks/pipx.yml

View File

@ -0,0 +1,24 @@
- name: List installed pipx packages
ansible.builtin.shell: set -o pipefail && pipx list --short | awk '{print $1}'
register: installed_pipx_packages
changed_when: false
- name: Define desired pipx packages
ansible.builtin.set_fact:
desired_pipx_packages:
- ansible
- ansible-lint
- shyaml
- name: Install pipx packages
community.general.pipx:
name: "{{ item }}"
state: present
loop: "{{ desired_pipx_packages }}"
when: item not in installed_pipx_packages.stdout_lines
- name: Remove undesired pipx packages
community.general.pipx:
name: "{{ item }}"
state: absent
loop: "{{ installed_pipx_packages.stdout_lines | difference(desired_pipx_packages) }}"