Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that OS package conflicts can be handled properly #194

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions molecule/_shared/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ ENV {{ var }} {{ value }}

RUN if [ $(command -v apt-get) ]; then \
if grep -q "Debian GNU/Linux 10" /etc/os-release; then \
apt-get update && apt-get install -y systemd python sudo bash ca-certificates iproute2 python-apt-common && apt-get clean; \
apt-get update && apt-get install -y systemd python sudo bash ca-certificates iproute2 python-apt python-apt-common && apt-get clean; \
elif grep -q "Debian GNU/Linux 11" /etc/os-release; then \
apt-get update && apt-get install -y systemd python sudo bash ca-certificates iproute2 python-apt-common && apt-get clean; \
apt-get update && apt-get install -y systemd python sudo bash ca-certificates iproute2 python3-apt python-apt-common && apt-get clean; \
else \
apt-get update && apt-get install -y systemd python3 sudo bash ca-certificates iproute2 python3-apt && apt-get clean; \
fi \
Expand Down
27 changes: 23 additions & 4 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
---
# File: install.yml - package installation tasks for Nomad # noqa 106

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

- name: Initialize a fact with the OS packages to install
ansible.builtin.set_fact:
nomad_os_packages_fact: []
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 + [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 # 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
14 changes: 7 additions & 7 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# 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 %}"
15 changes: 9 additions & 6 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
# 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
Loading