ansible: Add support for SLES to docker role
authorKienan Stewart <kstewart@efficios.com>
Wed, 31 Jan 2024 19:41:09 +0000 (14:41 -0500)
committerKienan Stewart <kstewart@efficios.com>
Fri, 2 Feb 2024 14:07:03 +0000 (09:07 -0500)
Change-Id: Ie217bf343e8d7564cba800818cf5bb3ccc087a97
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
automation/ansible/roles/docker/defaults/main.yml
automation/ansible/roles/docker/tasks/main.yml
automation/ansible/roles/docker/tasks/setup-Debian.yml [new file with mode: 0644]
automation/ansible/roles/docker/tasks/setup-Suse.yml [new file with mode: 0644]
automation/ansible/roles/docker/vars/SLES-15.yml [new file with mode: 0644]

index a5f2b6d5b1f94e33edc6bdf4a9a0f428c1757196..ea6986d115bb2476185e36e58a6261258f59dcce 100644 (file)
@@ -11,3 +11,9 @@ docker_upstream_packages:
 docker_Debian_packages:
   - 'docker.io'
   - 'docker-compose'
+
+docker_sles_products:
+  - 'sle-module-containers'
+
+docker_SLES_packages:
+  - 'docker'
index 775c70c1b9d258061c600df5e67825647963a5f1..c8bbae3b17f96d3bd11fc46d4d18887ed4c39e17 100644 (file)
@@ -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 (file)
index 0000000..b670181
--- /dev/null
@@ -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 (file)
index 0000000..a2372f3
--- /dev/null
@@ -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 (file)
index 0000000..f14fb16
--- /dev/null
@@ -0,0 +1,4 @@
+---
+
+# Docker upstream only supports SLES s390x
+docker_upstream: false
This page took 0.024663 seconds and 4 git commands to generate.