Ansible playbook added
[eliot.git] / blueprints / iotgateway / playbooks / roles / docker / tasks / install.yml
diff --git a/blueprints/iotgateway/playbooks/roles/docker/tasks/install.yml b/blueprints/iotgateway/playbooks/roles/docker/tasks/install.yml
new file mode 100644 (file)
index 0000000..c72fe26
--- /dev/null
@@ -0,0 +1,100 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+- name: Check whether docker is already installed
+  command: which docker
+  register: result
+  ignore_errors: yes
+  no_log: True
+
+- debug:
+    msg: Docker is already present
+  when: result.stdout != ""
+
+- debug:
+# yamllint disable rule:line-length
+    msg: Ignore Uninstall Log , Docker not installed continue with Installation
+# yamllint disable rule:line-length
+  when: result.stdout == ""
+
+- name: "INSTALL: Installing docker update"
+  command: apt-get update -y
+  ignore_errors: yes
+  failed_when: false
+  no_log: True
+
+- name: "INSTALL: Installing docker upgrade"
+# yamllint disable rule:line-length
+  command: apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
+# yamllint disable rule:line-length
+  ignore_errors: yes
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- name: "INSTALL: Add repository"
+  shell: curl -sL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- name: "INSTALL: CA-Certificates"
+# yamllint disable rule:line-length
+  shell: sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs)  stable"
+# yamllint disable rule:line-length
+  ignore_errors: yes
+  failed_when: false
+  no_log: True
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- name: "INSTALL: Update....."
+  command: apt-get update -y
+  ignore_errors: yes
+  failed_when: false
+  no_log: True
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- name: "INSTALL: Installed docker"
+  command: apt-get install -y docker-ce docker-ce-cli containerd.io
+  ignore_errors: yes
+  when: result is failed and ansible_architecture == 'aarch64'
+
+- debug:
+    msg: "CentOS commands start"
+
+- name: "INSTALL:Installing docker "
+  command: yum install -y yum-utils
+  when: ansible_facts['distribution'] == "CentOS" and result is failed
+  ignore_errors: yes
+  no_log: true
+
+- name: "INSTALL: Add repo"
+  command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
+  when: ansible_facts['distribution'] == "CentOS" and result is failed
+  #ignore_error: yes
+  no_log: true
+
+- name: "INSTALL: install containerd.io"
+  command: yum -y install docker-ce-19.03.8 docker-ce-cli-19.03.8 containerd.io
+  when: ansible_facts['distribution'] == "CentOS" and result is failed
+  ignore_errors: yes
+  no_log: true
+
+- name: "Start Docker:"
+  command: systemctl start docker
+  when: ansible_facts['distribution'] == "CentOS" and result is failed
+  ignore_errors: yes
+  #no_log: true
+
+- name: "Start Docker: enable"
+  command: systemctl enable docker
+  when: ansible_facts['distribution'] == "CentOS" and result is failed
+  ignore_errors: yes