Skip to content

Commit

Permalink
feat: change when (add version_compare)
Browse files Browse the repository at this point in the history
  • Loading branch information
victorely committed Oct 15, 2024
1 parent 30e4379 commit 0c179e2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tasks/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
- name: Set specific packages based on Ubuntu version
set_fact:
specific_packages: >-
{{ ubuntu_22_packages if ansible_distribution == 'Ubuntu' and ansible_distribution_version == '22' else
ubuntu_24_packages if ansible_distribution == 'Ubuntu' and ansible_distribution_version == '24' else [] }}
{{ ubuntu_22_packages if ansible_distribution == 'Ubuntu' and ansible_distribution_version is version_compare('22', '<=') else
ubuntu_24_packages if ansible_distribution == 'Ubuntu' and ansible_distribution_version is version_compare('24', '>=') else [] }}
- name: Install common and specific packages
package:
Expand All @@ -36,16 +36,17 @@
- python-setuptools
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '7'

- name: Install pip packages with extra args for Ubuntu 24
- name: Install pip packages with extra args for Ubuntu 24 or more
pip:
executable: pipx
name: "{{ basic_pip_packages }}"
state: present
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '24'
extra_args: --break-system-packages
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version_compare('24', '>=')

- name: Install pip packages
pip:
executable: pip3
name: "{{ basic_pip_packages }}"
state: present
when: not (ansible_distribution == 'Ubuntu' and ansible_distribution_version == '24')
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version_compare('22', '<=')

0 comments on commit 0c179e2

Please sign in to comment.