From 131480e28b42f2c69f5f12378691af06c09cd9f8 Mon Sep 17 00:00:00 2001 From: Ruben Ruiz de Gauna Date: Tue, 9 Jan 2024 07:57:56 +0100 Subject: [PATCH] NR-164383 feat: install docker in old suse distributions --- .../docker_install/files/open-suse-15.1.repo | 6 ++++ .../tasks/install-docker-SLES.yaml | 7 +++- .../tasks/install-docker-SLES_old.yaml | 33 +++++++++++++++++++ .../roles/docker_install/tasks/main.yml | 2 +- .../roles/docker_install/vars/main.yml | 5 ++- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 caos.ansible_roles/roles/docker_install/files/open-suse-15.1.repo create mode 100644 caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES_old.yaml diff --git a/caos.ansible_roles/roles/docker_install/files/open-suse-15.1.repo b/caos.ansible_roles/roles/docker_install/files/open-suse-15.1.repo new file mode 100644 index 0000000..082789b --- /dev/null +++ b/caos.ansible_roles/roles/docker_install/files/open-suse-15.1.repo @@ -0,0 +1,6 @@ +[Docker] +name=Docker +enabled=1 +autorefresh=0 +baseurl=http://download.opensuse.org/distribution/leap/15.1/repo/oss/ +type=rpm-md diff --git a/caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES.yaml b/caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES.yaml index 6074edd..b147747 100644 --- a/caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES.yaml +++ b/caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES.yaml @@ -9,8 +9,13 @@ force: yes retries: 5 delay: 60 + when: ansible_distribution_version not in suse_versions_wo_docker + +- name: install docker in old version + ansible.builtin.include_tasks: "install-docker-SLES_old.yaml" + when: ansible_distribution_version in suse_versions_wo_docker - name: install docker-compose (manual) shell: "DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} && mkdir -p $DOCKER_CONFIG/cli-plugins && mkdir -p /usr/local/lib/docker/cli-plugins/ && curl -SL https://github.com/docker/compose/releases/download/v{{ docker_compose_version }}/docker-compose-linux-{{ ansible_architecture }} -o $DOCKER_CONFIG/cli-plugins/docker-compose && sudo cp $DOCKER_CONFIG/cli-plugins/docker-compose /usr/local/lib/docker/cli-plugins/docker-compose && sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose" -... \ No newline at end of file +... diff --git a/caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES_old.yaml b/caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES_old.yaml new file mode 100644 index 0000000..32e2e19 --- /dev/null +++ b/caos.ansible_roles/roles/docker_install/tasks/install-docker-SLES_old.yaml @@ -0,0 +1,33 @@ +--- + +# Use OpenSUSE 15.1 repo to install docker +- name: install OpenSUSE 15.1 repo for docker + copy: + src: open-suse-15.1.repo + dest: /etc/zypp/repos.d/open-suse-15.1.repo + +- name: zypper refresh Docker + command: zypper refresh Docker + + # python-PyYAML is used by aws-cli that we don't use in canaries +- name: remove python-PyYAML that conflicts with this version of docker + zypper: + name: "python-PyYAML" + state: absent + oldpackage: yes + update_cache: yes + force: yes + +- name: install docker and docker-compose + command: zypper install -y --from Docker docker + +# remove repo +- name: install OpenSUSE 15.1 repo for docker + file: + path: /etc/zypp/repos.d/open-suse-15.1.repo + state: absent + +- name: zypper refresh + command: zypper refresh + +... diff --git a/caos.ansible_roles/roles/docker_install/tasks/main.yml b/caos.ansible_roles/roles/docker_install/tasks/main.yml index 1bd4d6f..c9cf553 100644 --- a/caos.ansible_roles/roles/docker_install/tasks/main.yml +++ b/caos.ansible_roles/roles/docker_install/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: install docker - include: "install-docker-{{ ansible_distribution }}.yaml" + ansible.builtin.include_tasks: "install-docker-{{ ansible_distribution }}.yaml" - name: ensure docker service is started ansible.builtin.service: diff --git a/caos.ansible_roles/roles/docker_install/vars/main.yml b/caos.ansible_roles/roles/docker_install/vars/main.yml index 1a054a8..0320dd4 100644 --- a/caos.ansible_roles/roles/docker_install/vars/main.yml +++ b/caos.ansible_roles/roles/docker_install/vars/main.yml @@ -1 +1,4 @@ -docker_compose_version: 2.12.2 \ No newline at end of file +docker_compose_version: 2.12.2 +suse_versions_wo_docker: + - "12.3" + - "12.4"