Docker roles added 87/3487/3
authorArvind Patel <arvind.patel@huawei.com>
Tue, 19 May 2020 10:33:00 +0000 (16:03 +0530)
committerGaurav Agrawal <gaurav.agrawal@huawei.com>
Tue, 19 May 2020 13:42:53 +0000 (13:42 +0000)
Change-Id: I454c117c18159bda7917e504ac2f77fe1f6c2cbb

ocd/infra/playbooks/ealt-all.yml
ocd/infra/playbooks/roles/docker/tasks/install.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/docker/tasks/main.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/docker/tasks/uninstall.yml [new file with mode: 0644]

index fc59ff6..48880a9 100644 (file)
@@ -61,6 +61,7 @@
   - mep
 
   roles:
+  - docker
   - k3s
   - helm
   - rabbitmq
diff --git a/ocd/infra/playbooks/roles/docker/tasks/install.yml b/ocd/infra/playbooks/roles/docker/tasks/install.yml
new file mode 100644 (file)
index 0000000..caded2e
--- /dev/null
@@ -0,0 +1,60 @@
+# 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
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: Docker is already present
+  when: result.rc == 0
+
+- meta: end_play
+  when: result.rc == 0
+
+- name: "Installing docker update"
+  command: apt-get update -y
+  ignore_errors: yes
+  failed_when: false
+  no_log: True
+
+- name: "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
+
+- name: Add repository
+  shell: curl -sL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+
+- name: "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
+
+- name: "Update....."
+  command: apt-get update -y
+  ignore_errors: yes
+  failed_when: false
+  no_log: True
+
+- name: "Installed docker"
+  command: apt-get install -y docker-ce docker-ce-cli containerd.io
+  ignore_errors: yes
diff --git a/ocd/infra/playbooks/roles/docker/tasks/main.yml b/ocd/infra/playbooks/roles/docker/tasks/main.yml
new file mode 100644 (file)
index 0000000..39f13a2
--- /dev/null
@@ -0,0 +1,25 @@
+# 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.
+
+---
+# tasks file for docker
+- name: Helm install
+  debug:
+    msg: installing helm
+
+- include: "install.yml"
+  when: operation == 'install'
+
+- include: "uninstall.yml"
+  when: operation == 'uninstall'
diff --git a/ocd/infra/playbooks/roles/docker/tasks/uninstall.yml b/ocd/infra/playbooks/roles/docker/tasks/uninstall.yml
new file mode 100644 (file)
index 0000000..5a01922
--- /dev/null
@@ -0,0 +1,51 @@
+# 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 installed before deleting
+  command: docker version
+  register: result
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: Docker is not present
+  when: result.rc == 2
+
+- meta: end_play
+  when: result.rc == 2
+
+- name: "Uninstall docker engine"
+  command: apt-get purge -y docker-engine
+  ignore_errors: yes
+
+- name: "Uninstall docker"
+  command: apt-get purge -y docker
+  ignore_errors: yes
+  #when: result is succeeded and ansible_architecture == 'x86_64'
+
+- name: "Uninstall docker.io"
+  command: apt-get purge -y docker.io
+  ignore_errors: yes
+  #when: result is succeeded and ansible_architecture == 'aarch64'
+
+- name: "Uninstall docker-ce"
+  command: apt-get purge -y docker-ce
+  ignore_errors: yes
+  #when: result is succeeded and ansible_architecture == 'aarch64'
+
+- name: "Uninstall docker"
+  command: apt-get purge -y docker-ce-cli
+  ignore_errors: yes
+  #when: result is succeeded