Skip to content

Commit

Permalink
Ensure that OS package conflicts can be handled properly
Browse files Browse the repository at this point in the history
  • Loading branch information
dosera committed Mar 21, 2024
1 parent 821effa commit 591de05
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 19 deletions.
30 changes: 26 additions & 4 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
---
# File: install.yml - package installation tasks for Nomad # noqa 106

- name: Gather the OS packages
ansible.builtin.package_facts:
manager: auto
tags: installation

- name: Set a fact with the OS packages to really install
ansible.builtin.set_fact:
nomad_os_packages_fact: "{{ nomad_os_packages_fact | default([]) + [item] }}"
with_items: "{{ nomad_os_packages }}"
tags: installation
when:
- item.handle is not defined or item.handle != 'skip'
- item.conflicts is not defined or item.conflicts not in ansible_facts.packages

- name: Install OS packages
ansible.builtin.package:
name: "{{ item }}"
name: "{{ item.name }}"
state: present
with_items: "{{ nomad_os_packages }}"
with_items: "{{ nomad_os_packages_fact }}"
tags: installation
when: not ansible_facts['os_family'] == "VMware Photon OS"

- name: Install OS packages
ansible.builtin.package:
name: "{{ item.name }}"
state: present
with_items: "{{ nomad_os_packages_fact }}"
tags: installation
when: not ansible_facts['os_family'] == "VMware Photon OS"

- name: Install OS packages # noqa no-changed-when
ansible.builtin.command: tdnf install {{ item }}
with_items: "{{ nomad_os_packages }}"
ansible.builtin.command: tdnf install {{ item.name }}
with_items: "{{ nomad_os_packages_fact }}"
tags: installation
when: ansible_facts['os_family'] == "VMware Photon OS"

Expand Down
2 changes: 1 addition & 1 deletion vars/Archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# File: Archlinux.yml - Archlinux variables for Nomad

nomad_os_packages:
- unzip
- name: unzip

nomad_syslog_enable: false
22 changes: 15 additions & 7 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
# File: vars/Debian.yml - Debian OS variables for Nomad

nomad_os_packages:
- curl
- git
- "{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('22.10', '<')) or (ansible_distribution == 'Debian' and ansible_distribution_version
is version('12', '<')) %}libcgroup1{% else %}libcgroup2{% endif %}"
- unzip
- "{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('19', '<')) or (ansible_distribution == 'Debian' and ansible_distribution_version
is version('11', '<')) %}cgroup-bin{% else %}cgroup-tools{% endif %}"
- name: curl
- name: git
- name: "{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('22.10', '<'))
or (ansible_distribution == 'Debian' and ansible_distribution_version is version('12', '<')) %}
libcgroup1
{% else %}
libcgroup2
{% endif %}"
- name: unzip
- name: "{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('19', '<'))
or (ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '<')) %}
cgroup-bin
{% else %}
cgroup-tools
{% endif %}"
19 changes: 13 additions & 6 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
# File: vars/RedHat.yml - Red Hat OS variables for Nomad

nomad_os_packages:
- "{% if (ansible_distribution == 'AlmaLinux' and ansible_distribution_version is version('9', '>=')) %}curl-minimal{% else %}curl{% endif %}"
- git
- "{% if (ansible_distribution == 'Fedora' and ansible_distribution_version is version('28', '<')) or (ansible_distribution == 'CentOS' and ansible_distribution_version
is version('8', '<')) or (ansible_distribution == 'Amazon' and ansible_distribution_version is version('3', '<')) or (ansible_distribution == 'OracleLinux' and
ansible_distribution_version is version('8', '<')) %}libselinux-python{% else %}python3-libselinux{% endif %}"
- unzip
- name: curl
conflicts: curl-minimal
handle: skip
- name: git
- name: "{% if (ansible_distribution == 'Fedora' and ansible_distribution_version is version('28', '<'))
or (ansible_distribution == 'CentOS' and ansible_distribution_version is version('8', '<'))
or (ansible_distribution == 'Amazon' and ansible_distribution_version is version('3', '<'))
or (ansible_distribution == 'OracleLinux' and ansible_distribution_version is version('8', '<')) %}
libselinux-python
{% else %}
python3-libselinux
{% endif %}"
- name: unzip
2 changes: 1 addition & 1 deletion vars/VMware Photon OS.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
nomad_os_packages:
- unzip
- name: unzip

0 comments on commit 591de05

Please sign in to comment.