Adding Ubuntu support in Ansible - docker-dind role 83/103783/4
authorJan Benedikt <j.benedikt@partner.samsung.com>
Tue, 17 Mar 2020 10:39:38 +0000 (11:39 +0100)
committerJan Benedikt <j.benedikt@partner.samsung.com>
Tue, 17 Mar 2020 15:31:35 +0000 (16:31 +0100)
Extending ansible playbooks of ubuntu support.

Issue-ID: OOM-1671
Signed-off-by: Jan Benedikt <j.benedikt@partner.samsung.com>
Change-Id: I6028736b54ce825d3eae257ca61cb6efab19a913

ansible/test/images/docker/ubuntu/Dockerfile
ansible/test/roles/prepare-docker-dind/tasks/main.yml
ansible/test/roles/prepare-docker-dind/tasks/rhel.yml [new file with mode: 0644]
ansible/test/roles/prepare-docker-dind/tasks/ubuntu.yml [new file with mode: 0644]

index 5441637..1828c5b 100644 (file)
@@ -4,8 +4,11 @@ FROM ubuntu:${RELEASE}
 # Systemd requires this env for ConditionVirtualization setting in unit files
 ENV container docker
 
-# Python2.7 required by ansible
-RUN apt-get update && apt-get -y install dbus systemd python openssh-server
+# Install necessary packages
+RUN apt-get update && apt-get -y install dbus systemd openssh-server
+
+# Create symlink python3 -> python
+RUN ln -s /usr/bin/python3 /usr/bin/python
 
 EXPOSE 22
 
index c0bf154..50efe14 100644 (file)
@@ -1,24 +1,6 @@
 ---
-# Needed because host system has all mounts by default to shared, and
-# some things may depend on mounts being shared if we run docker inside
-# test env.
-- name: "Make all mounts shared"
-  command: "mount --make-rshared /"
-  args:
-    warn: false
+- include: rhel.yml
+  when: ansible_distribution in ["CentOS","Red Hat Enterprise Linux"]
 
-- name: "Enable docker repository"
-  yum_repository:
-    name: "Docker"
-    description: Docker-ce repository
-    enabled: yes
-    baseurl: "https://download.docker.com/linux/centos/7/$basearch/stable"
-    gpgcheck: yes
-    gpgkey: https://download.docker.com/linux/centos/gpg
-
-- name: "Install docker"
-  package:
-    name: "docker-ce-{{ docker_version }}"
-    state: present
-    allow_downgrade: true
-  notify: Restart docker
+- include: ubuntu.yml
+  when: ansible_distribution in ["Ubuntu","Debian"]
\ No newline at end of file
diff --git a/ansible/test/roles/prepare-docker-dind/tasks/rhel.yml b/ansible/test/roles/prepare-docker-dind/tasks/rhel.yml
new file mode 100644 (file)
index 0000000..4184ef0
--- /dev/null
@@ -0,0 +1,24 @@
+---
+# Needed because host system has all mounts by default to shared, and
+# some things may depend on mounts being shared if we run docker inside
+# test env.
+- name: "Make all mounts shared"
+  command: "mount --make-rshared /"
+  args:
+    warn: false
+
+- name: "Enable docker repository - yum"
+  yum_repository:
+    name: "Docker"
+    description: Docker-ce repository
+    enabled: yes
+    baseurl: "https://download.docker.com/linux/centos/7/$basearch/stable"
+    gpgcheck: yes
+    gpgkey: https://download.docker.com/linux/centos/gpg
+
+- name: "Install docker"
+  package:
+    name: "docker-ce-{{ docker_version }}"
+    state: present
+    allow_downgrade: true
+  notify: Restart docker
diff --git a/ansible/test/roles/prepare-docker-dind/tasks/ubuntu.yml b/ansible/test/roles/prepare-docker-dind/tasks/ubuntu.yml
new file mode 100644 (file)
index 0000000..a41c4c2
--- /dev/null
@@ -0,0 +1,33 @@
+---
+# Needed because host system has all mounts by default to shared, and
+# some things may depend on mounts being shared if we run docker inside
+# test env.
+- name: "Make all mounts shared"
+  command: "mount --make-rshared /"
+  args:
+    warn: false
+
+- name: "Install GNUPG for apt-key"
+  package:
+    name: "gnupg"
+    state: present
+
+- name: "Add an apt key"
+  apt_key:
+      url: https://download.docker.com/linux/ubuntu/gpg
+      id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
+      state: present
+
+- name: "Enable docker repository - apt"
+  apt_repository:
+    repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
+    state: present
+    validate_certs: true
+    filename: "Docker"
+
+- name: "Install docker - apt"
+  apt:
+    name: "docker-ce"
+    state: present
+    update_cache: true
+  notify: Restart docker