1 # Copyright 2020 Huawei Technologies Co., Ltd.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 - name: Check whether docker is already installed
23 msg: Docker is already present
24 when: result.stdout != ""
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 == ""
32 - name: "INSTALL: Installing docker update"
33 command: apt-get update -y
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
43 when: result is failed and ansible_architecture == 'aarch64'
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'
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
56 when: result is failed and ansible_architecture == 'aarch64'
58 - name: "INSTALL: Update....."
59 command: apt-get update -y
63 when: result is failed and ansible_architecture == 'aarch64'
65 - name: "INSTALL: Installed docker"
66 command: apt-get install -y docker-ce docker-ce-cli containerd.io
68 when: result is failed and ansible_architecture == 'aarch64'
70 - name: "INSTALL: Installing docker upgrade"
71 # yamllint disable rule:line-length
72 command: apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
73 # yamllint disable rule:line-length
75 when: result is failed and ansible_architecture == 'x86_64'
77 - name: "INSTALL: Add repository"
78 shell: curl -sL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
79 when: result is failed and ansible_architecture == 'x86_64'
81 - name: "INSTALL: CA-Certificates"
82 # yamllint disable rule:line-length
83 shell: sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
84 # yamllint disable rule:line-length
88 when: result is failed and ansible_architecture == 'x86_64'
90 - name: "INSTALL: Update....."
91 command: apt-get update -y
95 when: result is failed and ansible_architecture == 'x86_64'
97 - name: "INSTALL: Installed docker"
98 command: apt-get install -y docker-ce docker-ce-cli containerd.io
100 when: result is failed and ansible_architecture == 'x86_64'
103 msg: "CentOS commands start"
105 - name: "INSTALL:Installing docker "
106 command: yum install -y yum-utils
107 when: ansible_facts['distribution'] == "CentOS" and result is failed
111 - name: "INSTALL: Add repo"
112 command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
113 when: ansible_facts['distribution'] == "CentOS" and result is failed
117 - name: "INSTALL: install containerd.io"
118 command: yum -y install docker-ce-19.03.8 docker-ce-cli-19.03.8 containerd.io
119 when: ansible_facts['distribution'] == "CentOS" and result is failed
123 - name: "Start Docker:"
124 command: systemctl start docker
125 when: ansible_facts['distribution'] == "CentOS" and result is failed
129 - name: "Start Docker: enable"
130 command: systemctl enable docker
131 when: ansible_facts['distribution'] == "CentOS" and result is failed