This commit is contained in:
Nk-dir 2025-10-08 18:45:26 +00:00 committed by GitHub
commit 00e3384c5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 62 additions and 3 deletions

View File

@ -18,4 +18,5 @@ platforms:
provisioner:
name: ansible
playbooks:
prepare: ${MOLECULE_PREPARE_PLAYBOOK:-prepare.yml}
converge: ${MOLECULE_PLAYBOOK:-converge.yml}

View File

@ -0,0 +1,34 @@
---
- name: Prepare
hosts: all
gather_facts: true
tasks:
- name: Install python3-apt for Debian/Ubuntu
apt:
name: python3-apt
state: present
update_cache: yes
when: ansible_facts.os_family == 'Debian'
- name: Install common packages for RedHat family (best-effort)
block:
- name: Try to install python3-dnf
package:
name: python3-dnf
state: present
- name: Try to install python3-libselinux
package:
name: python3-libselinux
state: present
when: ansible_facts.os_family == 'RedHat'
ignore_errors: true
- name: Install packages for Suse family (best-effort)
block:
- name: Try to install python3-zypp
package:
name: python3-zypp
state: present
when: ansible_facts.os_family == 'Suse'
ignore_errors: true

View File

@ -99,3 +99,13 @@
- include_tasks: docker-users.yml
when: at_least_one_user_to_modify is defined
- name: Add Docker apt repo
ansible.builtin.apt_repository:
repo: >-
deb [arch={{ ansible_facts.architecture }}]
{{ docker_repo_url }}/{{ docker_apt_ansible_distribution | lower }}
{{ ansible_facts['lsb']['codename'] | default(ansible_facts.get('distribution_release', '')) }}
{{ docker_apt_release_channel }}
filename: "{{ docker_apt_filename }}"
state: present
when: docker_add_repo | bool and ansible_facts.os_family == 'Debian'

View File

@ -16,9 +16,23 @@
state: absent
- name: Ensure legacy repo file is not present.
ansible.builtin.file:
path: "/etc/apt/sources.list.d/docker.list"
state: absent
block:
- name: Check for legacy docker.list
ansible.builtin.stat:
path: "/etc/apt/sources.list.d/docker.list"
register: legacy_docker_list
- name: Check whether legacy docker.list references the official Docker repo
ansible.builtin.command:
cmd: grep -q "{{ docker_repo_url }}" /etc/apt/sources.list.d/docker.list
register: legacy_grep
ignore_errors: true
changed_when: false
- name: Remove legacy docker.list if it does not reference the official Docker repo
ansible.builtin.file:
path: "/etc/apt/sources.list.d/docker.list"
state: absent
when: legacy_docker_list.stat.exists and legacy_grep.rc != 0
- name: Ensure dependencies are installed.
ansible.builtin.apt: