Add Suse Support

This commit is contained in:
Houssem Ben Ali 2025-09-30 16:50:32 +02:00
parent 639102d684
commit f04ad931db
No known key found for this signature in database
GPG Key ID: 049BFBE52CB08FC1
5 changed files with 73 additions and 1 deletions

View File

@ -46,6 +46,7 @@ docker_obsolete_packages:
- [`RedHat.yaml`](./vars/RedHat.yml)
- [`Debian.yaml`](./vars/Debian.yml)
- [`Suse.yaml`](./vars/Suse.yml)
A list of packages to be uninstalled prior to running this role. See [Docker's installation instructions](https://docs.docker.com/engine/install/debian/#uninstall-old-versions) for an up-to-date list of old packages that should be removed.

View File

@ -30,6 +30,12 @@ galaxy_info:
- name: ArchLinux
versions:
- all
- name: SLES
versions:
- all
- name: openSUSE
versions:
- all
galaxy_tags:
- web
- system

View File

@ -13,6 +13,9 @@
- include_tasks: setup-RedHat.yml
when: ansible_facts.os_family == 'RedHat'
- include_tasks: setup-Suse.yml
when: ansible_facts.os_family == 'Suse'
- include_tasks: setup-Debian.yml
when: ansible_facts.os_family == 'Debian'
@ -39,7 +42,7 @@
state: "{{ docker_compose_package_state }}"
notify: restart docker
ignore_errors: "{{ ansible_check_mode }}"
when: "docker_install_compose_plugin | bool == true and (ansible_version.full is version_compare('2.12', '<') or ansible_facts.os_family not in ['RedHat', 'Debian'])"
when: "docker_install_compose_plugin | bool == true and (ansible_version.full is version_compare('2.12', '<') or ansible_facts.os_family not in ['RedHat', 'Debian', 'Suse'])"
- name: Install docker-compose-plugin (with downgrade option).
package:

27
tasks/setup-Suse.yml Normal file
View File

@ -0,0 +1,27 @@
---
- name: Ensure old versions of Docker are not installed.
package:
name:
- docker
- docker-engine
- docker.io
- docker-ce
- docker-ce-cli
state: absent
- name: Add Docker repository (openSUSE / SLES).
zypper_repository:
name: "docker-ce"
repo: "{{ docker_zypper_repo_url }}"
state: present
auto_import_keys: yes
when: docker_add_repo | bool
- name: Refresh zypper repositories.
command: zypper --non-interactive refresh
when: docker_add_repo | bool
- name: Ensure Docker packages are installed.
ansible.legacy.zypper:
name: "{{ docker_packages }}"
state: present

35
vars/Suse.yml Normal file
View File

@ -0,0 +1,35 @@
---
# Used only for openSUSE / SLES (Suse OS-Family)
# https://en.opensuse.org/Docker
# https://docs.docker.com/engine/install/binaries/
docker_obsolete_packages:
- docker-engine
- docker.io
- docker-ce
- docker-ce-cli
- docker-buildx-plugin
- docker-ce-rootless-extras
- containerd.io
- runc
# SUSE provides a monolithic "docker" package and companions.
docker_packages:
- docker
- containerd
- docker-runc
docker_suse_release: >-
{{ 'openSUSE_Leap_15.5'
if ansible_distribution_version is match('15\.5')
else 'openSUSE_Leap_15.4'
if ansible_distribution_version is match('15\.4')
else 'openSUSE_Tumbleweed'
if ansible_distribution == 'openSUSE Tumbleweed'
else 'openSUSE_Leap_' + ansible_distribution_version }}
# Official repo for openSUSE Leap (adjust $releasever if needed)
docker_zypper_repo_url: "https://download.opensuse.org/repositories/Virtualization:/containers/{{ docker_suse_release }}/"
docker_add_repo: true