Skip to content

Commit

Permalink
Added new distros and insecure mode (#173)
Browse files Browse the repository at this point in the history
* Added 'docker_allow_unauthenticated' and 'docker_disable_gpg_check' setting
* Added support for 'Amazon' and 'OracleLinux' distributions
  • Loading branch information
palyla authored Jul 8, 2024
1 parent 23e372a commit efb5db5
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 2 deletions.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,6 @@ docker_remove_all: false
# Additional files or directories to be remove if for example non-standard locations
# was previously configured for data storage etc.
docker_remove_additional: []
# It bypasses GPG keys checking for package manager
docker_allow_unauthenticated: no
docker_disable_gpg_check: no
2 changes: 2 additions & 0 deletions tasks/bug-tweaks/lvm-thinpool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
ansible.builtin.package:
name: lvm2
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _pkg_result
until: _pkg_result is succeeded

Expand Down
3 changes: 3 additions & 0 deletions tasks/checks/distribution-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
msg: "Distribution {{ _docker_os_dist }} is not supported by this role!"
vars:
_supported_distributions:
- Amazon
- OracleLinux
- CloudLinux
- AlmaLinux
- CentOS
- Debian
Expand Down
4 changes: 4 additions & 0 deletions tasks/configure-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
ansible.builtin.package:
name: lvm2
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _pkg_result
until: _pkg_result is succeeded

Expand All @@ -95,6 +97,8 @@
ansible.builtin.package:
name: thin-provisioning-tools
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _pkg_result
until: _pkg_result is succeeded

Expand Down
11 changes: 11 additions & 0 deletions tasks/install-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
_docker_packages:
- docker-ce

- name: Ensure some kind of compatibility for no longer officially supported distributions since Docker CE 18.09
when:
- _docker_packages is not defined
- (_docker_os_dist == "Amazon" and _docker_os_dist_major_version | int >= 2023)
ansible.builtin.set_fact:
_docker_packages:
- docker

- name: Do workaround to handle CentOS/RHEL 8 installation issues
when:
- _docker_packages is not defined
Expand All @@ -45,6 +53,9 @@
ansible.builtin.package:
name: "{{ (item is search('docker-ce')) | ternary((item + _docker_version_string | default('')), item) }}"
state: "{{ _docker_pkg_state | default('present') }}"
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"

loop: "{{ _docker_packages | default(docker_packages) }}"
register: _docker_pkg_result
retries: 6
Expand Down
17 changes: 15 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
_docker_os_dist_file_varity: "RedHat"
tags: ["install", "configure", "postinstall", "docker_install", "docker_configure", "docker_postinstall"]

- name: Reinterpret distribution facts for Amazon Linux
when: _docker_os_dist == "Amazon"
ansible.builtin.set_fact:
_docker_os_dist_file_varity: "RedHat"
tags: ["install", "configure", "postinstall", "docker_install", "docker_configure", "docker_postinstall"]

- name: Reinterpret distribution facts for Debian 10 (Buster) due to bug
when:
- _docker_os_dist == "Debian"
Expand All @@ -44,14 +50,22 @@
_docker_os_dist_major_version: 10
tags: ["install", "configure", "postinstall", "docker_install", "docker_configure", "docker_postinstall"]

- name: Check if /etc/os-release exists
stat:
path: /etc/os-release
register: _os_release
tags: ["install", "configure", "postinstall", "docker_install", "docker_configure", "docker_postinstall"]

- name: OS release info
when: _os_release.stat.exists
ansible.builtin.raw: cat /etc/os-release
check_mode: no
changed_when: no
register: _docker_os_release_info
tags: ["install", "configure", "postinstall", "docker_install", "docker_configure", "docker_postinstall"]

- name: Print OS release information
when: _os_release.stat.exists
ansible.builtin.debug:
var: _docker_os_release_info
verbosity: 1
Expand All @@ -66,8 +80,7 @@
tags: ["install", "configure", "postinstall", "docker_install", "docker_configure", "docker_postinstall"]

- name: Reinterpret distribution facts for Raspbian
when:
- _docker_os_release_info.stdout is search('raspbian')
when: _os_release.stat.exists and _docker_os_release_info.stdout is search('raspbian')
ansible.builtin.set_fact:
_docker_os_arch: "armhf"
tags: ["install", "configure", "postinstall", "docker_install", "docker_configure", "docker_postinstall"]
Expand Down
4 changes: 4 additions & 0 deletions tasks/postinstall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
ansible.builtin.package:
name: "epel-release"
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _pkg_result
until: _pkg_result is succeeded

Expand All @@ -99,6 +101,8 @@
ansible.builtin.package:
name: "{{ item }}"
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
loop: "{{ _docker_additional_packages_os }}"
register: _pkg_result
until: _pkg_result is succeeded
Expand Down
3 changes: 3 additions & 0 deletions tasks/remove-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
ansible.builtin.package:
name: "{{ item }}"
state: absent
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
loop: "{{ docker_packages }}"
register: _pkg_result
until: _pkg_result is succeeded
Expand All @@ -27,6 +29,7 @@
name: "{{ item }}"
state: absent
purge: yes
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
loop: "{{ docker_packages }}"
register: _pkg_result
until: _pkg_result is succeeded
Expand Down
2 changes: 2 additions & 0 deletions tasks/remove-pre-docker-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
ansible.builtin.package:
name: "{{ item }}"
state: absent
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _pkg_result
until: _pkg_result is succeeded
loop: "{{ docker_old_packages[_docker_os_dist] | default(docker_old_packages[_docker_os_dist_file_varity]) }}"
2 changes: 2 additions & 0 deletions tasks/setup-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
ansible.builtin.package:
name: auditd
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _pkg_result
until: _pkg_result is succeeded

Expand Down
3 changes: 3 additions & 0 deletions tasks/setup-repository-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
become: true
ansible.builtin.apt:
update_cache: yes
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
changed_when: false
register: _pkg_result
until: _pkg_result is succeeded
Expand All @@ -27,6 +28,8 @@
ansible.builtin.package:
name: "{{ item }}"
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
loop: "{{ docker_repository_related_packages[_docker_os_dist_file_varity] }}"
register: _pkg_result
until: _pkg_result is succeeded
Expand Down
2 changes: 2 additions & 0 deletions tasks/setup-repository-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
ansible.builtin.package:
name: "{{ item }}"
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
loop: "{{ docker_repository_related_packages[_docker_os_dist_file_varity] }}"
register: _pkg_result
until: _pkg_result is succeeded
Expand Down
1 change: 1 addition & 0 deletions tasks/setup-repository.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- name: Include setup repository tasks for distribution variety {{ _docker_os_dist_file_varity }}
when: (_docker_os_dist == "Amazon" and _docker_os_dist_major_version | int < 2023) or _docker_os_dist != "Amazon"
ansible.builtin.include_tasks: setup-repository-{{ _docker_os_dist_file_varity }}.yml

- name: Update repository cache
Expand Down
1 change: 1 addition & 0 deletions tests/experimental/kata/test_katacontainers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
yum:
name: "{{ item }}"
update_cache: yes
disable_gpg_check: "{{ disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
loop:
- kata-runtime
- kata-proxy
Expand Down
2 changes: 2 additions & 0 deletions tests/host_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
package:
name: "*"
state: latest
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _upgrade_all
when: ansible_distribution == "RedHat"
2 changes: 2 additions & 0 deletions tests/manual/test_remove_pre_ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package:
name: docker-latest
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
register: _pkg_result
until: _pkg_result is succeeded

Expand Down
2 changes: 2 additions & 0 deletions tests/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
package:
name: git
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
when: docker_bench_security is defined

- name: Ensure Docker Bench Security is cloned
Expand Down
4 changes: 4 additions & 0 deletions tests/prepare_storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
package:
name: "{{ item }}"
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
become: true
loop:
- parted
Expand All @@ -19,6 +21,8 @@
package:
name: e4fsprogs
state: present
allow_unauthenticated: "{{ docker_allow_unauthenticated if ansible_pkg_mgr == 'apt' else omit }}"
disable_gpg_check: "{{ docker_disable_gpg_check if ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] else omit }}"
become: true
when: ansible_distribution == "CentOS"

Expand Down

0 comments on commit efb5db5

Please sign in to comment.