From: Kienan Stewart Date: Wed, 31 Jan 2024 19:41:09 +0000 (-0500) Subject: ansible: Add support for SLES to docker role X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=30b28562b262df9cfcf243afe50b13100db58a8f;p=lttng-ci.git ansible: Add support for SLES to docker role Change-Id: Ie217bf343e8d7564cba800818cf5bb3ccc087a97 Signed-off-by: Kienan Stewart --- diff --git a/automation/ansible/roles/docker/defaults/main.yml b/automation/ansible/roles/docker/defaults/main.yml index a5f2b6d..ea6986d 100644 --- a/automation/ansible/roles/docker/defaults/main.yml +++ b/automation/ansible/roles/docker/defaults/main.yml @@ -11,3 +11,9 @@ docker_upstream_packages: docker_Debian_packages: - 'docker.io' - 'docker-compose' + +docker_sles_products: + - 'sle-module-containers' + +docker_SLES_packages: + - 'docker' diff --git a/automation/ansible/roles/docker/tasks/main.yml b/automation/ansible/roles/docker/tasks/main.yml index 775c70c..c8bbae3 100644 --- a/automation/ansible/roles/docker/tasks/main.yml +++ b/automation/ansible/roles/docker/tasks/main.yml @@ -1,20 +1,19 @@ --- - -- when: ansible_distribution_release in ['trixie', 'sid'] - ansible.builtin.set_fact: - docker_upstream: false -- ansible.builtin.set_fact: - docker_packages: "{{docker_upstream|ternary(docker_upstream_packages, lookup('vars', 'docker_' + ansible_distribution + '_packages', default=[]))}}" -- when: docker_upstream - block: - - name: Add upstream docker apt key - ansible.builtin.apt_key: - url: 'https://download.docker.com/linux/debian/gpg' - - name: Add upstream docker sources - when: ansible_distribution == 'Debian' - ansible.builtin.apt_repository: - filename: 'docker' - repo: "deb https://download.docker.com/linux/debian {{ansible_distribution_release}} stable" +- name: Include OS-specific variables + ansible.builtin.include_vars: "{{item}}" + with_first_found: + - files: + - "{{ansible_distribution}}-{{ansible_distribution_major_version}}.yml" + - "{{ansible_distribution}}-{{ansible_distribution_release}}.yml" + - "{{ansible_distribution}}.yml" + - "{{ansible_os_family}}.yml" + skip: true +- name: OS-specific setup + ansible.builtin.include_tasks: "{{item}}" + with_first_found: + - files: + - "setup-{{ansible_os_family}}.yml" + skip: true - name: Deploy docker network configuration block: - name: Create docker configuration directory diff --git a/automation/ansible/roles/docker/tasks/setup-Debian.yml b/automation/ansible/roles/docker/tasks/setup-Debian.yml new file mode 100644 index 0000000..b670181 --- /dev/null +++ b/automation/ansible/roles/docker/tasks/setup-Debian.yml @@ -0,0 +1,16 @@ +--- +- when: ansible_distribution_release in ['trixie', 'sid'] + ansible.builtin.set_fact: + docker_upstream: false +- ansible.builtin.set_fact: + docker_packages: "{{docker_upstream|ternary(docker_upstream_packages, lookup('vars', 'docker_' + ansible_distribution + '_packages', default=[]))}}" +- when: docker_upstream + block: + - name: Add upstream docker apt key + ansible.builtin.apt_key: + url: 'https://download.docker.com/linux/debian/gpg' + - name: Add upstream docker sources + when: ansible_distribution == 'Debian' + ansible.builtin.apt_repository: + filename: 'docker' + repo: "deb https://download.docker.com/linux/debian {{ansible_distribution_release}} stable" diff --git a/automation/ansible/roles/docker/tasks/setup-Suse.yml b/automation/ansible/roles/docker/tasks/setup-Suse.yml new file mode 100644 index 0000000..a2372f3 --- /dev/null +++ b/automation/ansible/roles/docker/tasks/setup-Suse.yml @@ -0,0 +1,12 @@ +--- + +- name: Add SLES products + when: ansible_distribution == 'SLES' + ansible.builtin.command: + argv: ['suseconnect', '-p', "{{product}}/{{ansible_distribution_version}}/{{ansible_architecture}}"] + loop: "{{docker_sles_products|default([])}}" + loop_control: + loop_var: product + +- ansible.builtin.set_fact: + docker_packages: "{{docker_SLES_packages}}" diff --git a/automation/ansible/roles/docker/vars/SLES-15.yml b/automation/ansible/roles/docker/vars/SLES-15.yml new file mode 100644 index 0000000..f14fb16 --- /dev/null +++ b/automation/ansible/roles/docker/vars/SLES-15.yml @@ -0,0 +1,4 @@ +--- + +# Docker upstream only supports SLES s390x +docker_upstream: false