Skip to content
Open
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
1 change: 1 addition & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ platforms:
provisioner:
name: ansible
playbooks:
prepare: ${MOLECULE_PREPARE_PLAYBOOK:-prepare.yml}
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
34 changes: 34 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
20 changes: 17 additions & 3 deletions tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading