c72fe26b36171b46c3c885761de453462ec917f0
[eliot.git] / blueprints / iotgateway / playbooks / roles / docker / tasks / install.yml
1 # Copyright 2020 Huawei Technologies Co., Ltd.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 ---
16 - name: Check whether docker is already installed
17   command: which docker
18   register: result
19   ignore_errors: yes
20   no_log: True
21
22 - debug:
23     msg: Docker is already present
24   when: result.stdout != ""
25
26 - debug:
27 # yamllint disable rule:line-length
28     msg: Ignore Uninstall Log , Docker not installed continue with Installation
29 # yamllint disable rule:line-length
30   when: result.stdout == ""
31
32 - name: "INSTALL: Installing docker update"
33   command: apt-get update -y
34   ignore_errors: yes
35   failed_when: false
36   no_log: True
37
38 - name: "INSTALL: Installing docker upgrade"
39 # yamllint disable rule:line-length
40   command: apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
41 # yamllint disable rule:line-length
42   ignore_errors: yes
43   when: result is failed and ansible_architecture == 'aarch64'
44
45 - name: "INSTALL: Add repository"
46   shell: curl -sL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
47   when: result is failed and ansible_architecture == 'aarch64'
48
49 - name: "INSTALL: CA-Certificates"
50 # yamllint disable rule:line-length
51   shell: sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs)  stable"
52 # yamllint disable rule:line-length
53   ignore_errors: yes
54   failed_when: false
55   no_log: True
56   when: result is failed and ansible_architecture == 'aarch64'
57
58 - name: "INSTALL: Update....."
59   command: apt-get update -y
60   ignore_errors: yes
61   failed_when: false
62   no_log: True
63   when: result is failed and ansible_architecture == 'aarch64'
64
65 - name: "INSTALL: Installed docker"
66   command: apt-get install -y docker-ce docker-ce-cli containerd.io
67   ignore_errors: yes
68   when: result is failed and ansible_architecture == 'aarch64'
69
70 - debug:
71     msg: "CentOS commands start"
72
73 - name: "INSTALL:Installing docker "
74   command: yum install -y yum-utils
75   when: ansible_facts['distribution'] == "CentOS" and result is failed
76   ignore_errors: yes
77   no_log: true
78
79 - name: "INSTALL: Add repo"
80   command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
81   when: ansible_facts['distribution'] == "CentOS" and result is failed
82   #ignore_error: yes
83   no_log: true
84
85 - name: "INSTALL: install containerd.io"
86   command: yum -y install docker-ce-19.03.8 docker-ce-cli-19.03.8 containerd.io
87   when: ansible_facts['distribution'] == "CentOS" and result is failed
88   ignore_errors: yes
89   no_log: true
90
91 - name: "Start Docker:"
92   command: systemctl start docker
93   when: ansible_facts['distribution'] == "CentOS" and result is failed
94   ignore_errors: yes
95   #no_log: true
96
97 - name: "Start Docker: enable"
98   command: systemctl enable docker
99   when: ansible_facts['distribution'] == "CentOS" and result is failed
100   ignore_errors: yes