From 8b623b2266ac6813ebc9dc3db24f7d607d09afb7 Mon Sep 17 00:00:00 2001 From: aurelien-bareille Date: Wed, 14 Dec 2022 16:31:46 +0100 Subject: [PATCH 1/3] Add flag to deactivate repository configuration --- defaults/main.yml | 3 +++ tasks/setup-Debian.yml | 6 ++++-- tasks/setup-RedHat.yml | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 685b8de..870a94c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,6 +26,9 @@ docker_compose_arch: "{{ ansible_architecture }}" docker_compose_url: "https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-linux-{{ docker_compose_arch }}" docker_compose_path: /usr/local/bin/docker-compose +# Enable repo setup +docker_add_repo: true + # Docker repo URL. docker_repo_url: https://download.docker.com/linux diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 27ef57b..f74fd0d 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -33,18 +33,20 @@ force: true register: add_repository_key ignore_errors: "{{ docker_apt_ignore_key_error }}" + when: docker_add_repo | bool - name: Ensure curl is present (on older systems without SNI). package: name=curl state=present - when: add_repository_key is failed + when: add_repository_key is failed and docker_add_repo | bool - name: Add Docker apt key (alternative for older systems without SNI). shell: > curl -sSL {{ docker_apt_gpg_key }} | apt-key add - - when: add_repository_key is failed + when: add_repository_key is failed and docker_add_repo | bool - name: Add Docker repository. apt_repository: repo: "{{ docker_apt_repository }}" state: present update_cache: true + when: docker_add_repo | bool diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index 676c9e5..ad337c4 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -11,6 +11,7 @@ rpm_key: key: "{{ docker_yum_gpg_key }}" state: present + when: docker_add_repo | bool - name: Add Docker repository. get_url: @@ -19,6 +20,7 @@ owner: root group: root mode: 0644 + when: docker_add_repo | bool - name: Configure Docker Nightly repo. ini_file: @@ -28,6 +30,7 @@ value: '{{ docker_yum_repo_enable_nightly }}' mode: 0644 no_extra_spaces: true + when: docker_add_repo | bool - name: Configure Docker Test repo. ini_file: @@ -37,6 +40,7 @@ value: '{{ docker_yum_repo_enable_test }}' mode: 0644 no_extra_spaces: true + when: docker_add_repo | bool - name: Configure containerd on RHEL 8. block: From 0ad2ddd2c6a0f14e712de2d93bef66f1965abf92 Mon Sep 17 00:00:00 2001 From: aurelien-bareille Date: Wed, 14 Dec 2022 18:25:29 +0100 Subject: [PATCH 2/3] Include repository setup dependancies in flag scope --- tasks/setup-Debian.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index f74fd0d..0abcd17 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -12,6 +12,7 @@ - apt-transport-https - ca-certificates state: present + when: docker_add_repo | bool - name: Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems). apt: From 61d571a9413abdd5955aa770e0b34c2ad6a28891 Mon Sep 17 00:00:00 2001 From: aurelien-bareille Date: Mon, 26 Dec 2022 16:53:42 +0100 Subject: [PATCH 3/3] Add documentation --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2f23291..953b7dd 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ Docker Compose Plugin installation options. These differ from the below in that Docker Compose installation options. + docker_add_repo: true + +Controls whether this role will add the official Docker repository. Set to `false` if you want to use the default docker packages for your system or manage the package repository on your own. + docker_repo_url: https://download.docker.com/linux The main Docker repo URL, common between Debian and RHEL systems.