Changed install and uninstall condition 04/3504/6
authorArvind Patel <arvind.patel@huawei.com>
Fri, 22 May 2020 18:47:34 +0000 (00:17 +0530)
committerArvind Patel <arvind.patel@huawei.com>
Fri, 22 May 2020 19:35:51 +0000 (01:05 +0530)
Change-Id: Ie19368d97c0e95de0ad46807db44818e78709c68

19 files changed:
ocd/infra/playbooks/ealt-all-uninstall.yml
ocd/infra/playbooks/ealt-all.yml
ocd/infra/playbooks/roles/docker/tasks/install.yml
ocd/infra/playbooks/roles/docker/tasks/main.yml
ocd/infra/playbooks/roles/docker/tasks/uninstall.yml
ocd/infra/playbooks/roles/grafana/tasks/install.yml
ocd/infra/playbooks/roles/grafana/tasks/main.yml
ocd/infra/playbooks/roles/grafana/tasks/uninstall.yml
ocd/infra/playbooks/roles/helm/tasks/install.yml
ocd/infra/playbooks/roles/helm/tasks/main.yml
ocd/infra/playbooks/roles/helm/tasks/uninstall.yml
ocd/infra/playbooks/roles/k3s/tasks/install.yml
ocd/infra/playbooks/roles/k3s/tasks/main.yml
ocd/infra/playbooks/roles/k3s/tasks/uninstall.yml
ocd/infra/playbooks/roles/k8s/tasks/main.yml
ocd/infra/playbooks/roles/prometheus/tasks/install.yml
ocd/infra/playbooks/roles/prometheus/tasks/main.yml
ocd/infra/playbooks/roles/rabbitmq/tasks/install.yml
ocd/infra/playbooks/roles/rabbitmq/tasks/main.yml

index d84f63f..8e76773 100644 (file)
@@ -44,6 +44,7 @@
   - prometheus
   - helm
   - k3s
+  - docker
 
 - hosts: infra-helm
   become: yes
index 43a6ef9..5e2d3cf 100644 (file)
@@ -70,6 +70,7 @@
   - prometheus
   - kubeconfig
   - cadvisor
+  - docker
 
 - hosts: mepautomate
   become: yes
index e411e16..649bac9 100644 (file)
 # yamllint disable rule:line-length
   when: result.stdout == ""
 
-- name: "Installing docker update"
+- name: "INSTALL: Installing docker update"
   command: apt-get update -y
   ignore_errors: yes
   failed_when: false
   no_log: True
 
-- name: "Installing docker upgrade"
+- 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: Add repository
+- 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: "CA-Certificates"
+- 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
   no_log: True
   when: result is failed and ansible_architecture == 'aarch64'
 
-- name: "Update....."
+- 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: "Installed docker"
+- 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'
index 4c99ef0..b8f4286 100644 (file)
@@ -15,7 +15,9 @@
 ---
 # tasks file for docker
 - include: "install.yml"
+  static: false
   when: operation == 'install'
 
 - include: "uninstall.yml"
+  static: false
   when: operation == 'uninstall'
index d011d18..b6920ef 100644 (file)
 # yamllint disable rule:line-length
   when: result.stdout == ""
 
-- name: "Uninstall docker engine"
+- name: "UNINSTALL: Uninstall docker engine"
   command: apt-get purge -y docker-engine
   ignore_errors: yes
   when: result is succeeded and ansible_architecture == 'aarch64'
 
-- name: "Uninstall docker"
+- name: "UNINSTALL: Uninstall docker"
   command: apt-get purge -y docker
   ignore_errors: yes
   when: result is succeeded and ansible_architecture == 'aarch64'
   #when: result is succeeded and ansible_architecture == 'x86_64'
 
-- name: "Uninstall docker.io"
+- name: "UNINSTALL: 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"
+- name: "UNINSTALL: Uninstall docker-ce"
   command: apt-get purge -y docker-ce
   ignore_errors: yes
   when: result is succeeded and ansible_architecture == 'aarch64'
   #when: result is succeeded and ansible_architecture == 'aarch64'
 
-- name: "Uninstall docker"
+- name: "UNINSTALL: Uninstall docker"
   command: apt-get purge -y docker-ce-cli
   ignore_errors: yes
   when: result is succeeded and ansible_architecture == 'aarch64'
index b2c6d7f..46245cb 100644 (file)
 # limitations under the License.
 
 ---
-- name: Install grafana on x86_64
+- name: check if grafana is already installed
+  shell:
+    cmd: helm status mec-grafana
+  register: result
+  ignore_errors: yes
+  no_log: True
+
+- debug:
+    msg: grafana is already present
+  when: result.stdout != ""
+
+- debug:
+# yamllint disable rule:line-length
+    msg: Ignore Uninstall Log , Grafana not installed continue with Installation
+# yamllint disable rule:line-length
+  when: result.stdout == ""
+
+- name: "INSTALL: Install grafana on x86_64"
   shell:
     cmd: helm install mec-grafana stable/grafana
   when: result is failed and ansible_architecture == 'x86_64'
 
-- name: copy values.yaml to host
+- name: "INSTALL: copy values.yaml to host"
   copy:
     src: values.yaml
     dest: /tmp/grafana/
   when: result is failed and ansible_architecture == 'aarch64'
 
-- name: Install grafana on aarch64
+- name: "INSTALL: Install grafana on aarch64"
   shell:
     cmd: helm install mec-grafana stable/grafana -f /tmp/grafana/values.yaml
   when: result is failed and ansible_architecture == 'aarch64'
index f6e7eac..db34791 100644 (file)
@@ -14,7 +14,8 @@
 
 ---
 - include: "install.yml"
+  static: false
   when: operation == 'install'
 
-- include: "uninstall.yml"
-  when: operation == 'uninstall'
+  #- include: "uninstall.yml"
+  #when: operation == 'uninstall'
index d4e5e33..6f08c57 100644 (file)
 # limitations under the License.
 
 ---
+- name: check if grafana is installed before deleting
+  shell:
+    cmd: helm status mec-grafana
+  register: result
+  ignore_errors: yes
+  no_log: True
+
+- debug:
+    msg: Uninstalling docker...
+  when: result.stdout != ""
+
+- debug:
+    msg: Ignore Uninstall Log , Grafana not installed
+  when: result.stdout == ""
+
 - name: Uninstall grafana
   shell:
     cmd: helm uninstall mec-grafana
index 5dc8a0c..f855091 100644 (file)
 # yamllint disable rule:line-length
   when: result.stdout == ""
 
-- name: "Helm download command on x86_64"
+- name: "INSTALL: Helm download command on x86_64"
   command: wget https://get.helm.sh/helm-v3.0.2-linux-amd64.tar.gz
   when: result is failed and ansible_architecture == 'x86_64'
 
-- name: "Untar helm on x86_64"
+- name: "INSTALL: Untar helm on x86_64"
   command: tar -zxvf helm-v3.0.2-linux-amd64.tar.gz
   when: result is failed and ansible_architecture == 'x86_64'
 
-- name: "Helm move to bin folder on x86_64"
+- name: "INSTALL: Helm move to bin folder on x86_64"
   command: mv linux-amd64/helm /usr/local/bin/
   when: result is failed and ansible_architecture == 'x86_64'
 
-- name: "Helm download command on aarch64"
+- name: "INSTALL: Helm download command on aarch64"
   command: wget https://get.helm.sh/helm-v3.0.2-linux-arm64.tar.gz
   when: result is failed and ansible_architecture == 'aarch64'
 
-- name: "Untar helm on aarch64"
+- name: "INSTALL: Untar helm on aarch64"
   command: tar -zxvf helm-v3.0.2-linux-arm64.tar.gz
   when: result is failed and ansible_architecture == 'aarch64'
 
-- name: "Helm move to bin folder on aarch64"
+- name: "INSTALL: Helm move to bin folder on aarch64"
   command: mv linux-arm64/helm /usr/local/bin/
   when: result is failed and ansible_architecture == 'aarch64'
 
-- name: "Add helm repo"
+- name: "INSTALL: Add helm repo"
 # yamllint disable rule:line-length
   command: helm repo add stable https://kubernetes-charts.storage.googleapis.com/
 # yamllint disable rule:line-length
   when: result is failed
 
-- name: "Updated helm repo"
+- name: "INSTALL: Updated helm repo"
   command: helm repo update
   when: result is failed
 
-- name: "List helm repo"
+- name: "INSTALLED List helm repo"
   command: helm repo list
   when: result is failed
index 79832a1..9619418 100644 (file)
@@ -15,7 +15,9 @@
 
 # tasks file for helm
 - include: "install.yml"
+  static: false
   when: operation == 'install'
 
 - include: "uninstall.yml"
+  static: false
   when: operation == 'uninstall'
index 7d75e32..78db3d1 100644 (file)
 # limitations under the License.
 
 ---
-- name: Helm Uninstall on x86_64
+- name: check whether helm is installed before deleting
+  command: which helm
+  register: result
+  ignore_errors: yes
+  no_log: True
+
+- debug:
+    msg: Uninstalling helm...
+  when: result.stdout != ""
+
+- debug:
+    msg: Ignore Uninstall Log ,Helm not installed
+  when: result.stdout == ""
+
+- name: "UNINSTALL: Helm Uninstall on x86_64"
   command: rm -rf linux-amd64/helm
   when: result is succeeded and ansible_architecture == 'x86_64'
 
-- name: Remove download helm file on x86_64
+- name: "UNINSTALL: Remove download helm file on x86_64"
   command: rm ~/helm-v3.0.2-linux-amd64.tar.gz
   when: result is succeeded and ansible_architecture == 'x86_64'
 
-- name: Helm Uninstall on aarch64
+- name: "UNINSTALL: Helm Uninstall on aarch64"
   command: rm -rf linux-arm64/helm
   ignore_errors: yes
   no_log: True
   when: result is succeeded and ansible_architecture == 'aarch64'
 
-- name: Remove download helm file on aarch64
+- name: "UNINSTALL: Remove download helm file on aarch64"
   command: rm helm-v3.0.2-linux-arm64.tar.gz
   ignore_errors: yes
   no_log: True
   when: result is succeeded and ansible_architecture == 'aarch64'
 
-- name: Remove helm from bin
+- name: "UNINSTALL: Remove helm from bin"
   command: rm /usr/local/bin/helm
   ignore_errors: yes
   no_log: True
index 5759241..70cde7c 100644 (file)
 
 - debug: var=ansible_host
 
-- name: Disabling firewall for successfull k3s installation on CentOs
+- name: "INSTALL: Disabling firewall for successfull k3s installation on CentOs"
   shell:
     cmd: systemctl stop firewalld
   when: ansible_facts['distribution'] == "CentOS" and result is failed
 
-- name: install container-selinux
+- name: "INSTALL: install container-selinux"
   shell:
     cmd: yum install -y container-selinux selinux-policy-base
   when: ansible_facts['distribution'] == "CentOS" and result is failed
   ignore_errors: true
 
-- name: install k3s-selinux-0.1.1-rc1.el7.noarch.rpm
+- name: "INSTALL: install k3s-selinux-0.1.1-rc1.el7.noarch.rpm"
   shell:
     cmd: rpm -i https://rpm.rancher.io/k3s-selinux-0.1.1-rc1.el7.noarch.rpm
   when: ansible_facts['distribution'] == "CentOS" and result is failed
   ignore_errors: true
 
-- name: get interface name
+- name: "INSTALL: get interface name"
   shell:
     cmd: ip a |grep {{ ansible_host }} |awk '{print $NF}'
   register: ifName
   when: result is failed
 
 # yamllint disable rule:line-length
-- name: install k3s
+- name: "INSTALL: install k3s"
   shell:
     cmd: curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--node-ip={{ ansible_host }} --node-external-ip={{ ansible_host }} --bind-address={{ ansible_host }} --flannel-iface=eth0 --docker --no-deploy=servicelb --no-deploy=traefik --write-kubeconfig-mode 644 --kube-apiserver-arg="service-node-port-range=30000-36000"" sh -
   when: result is failed
 
 # yamllint disable rule:line-length
 
-#- name: install k3s
+#- name: "INSTALL: install k3s"
 # shell:
 #    cmd: curl -sfL https://get.k3s.io | sh -
 #  when: result is failed
 
-- name: create .kube dir
+- name: "INSTALL: create .kube dir"
   shell:
     cmd: mkdir -p $HOME/.kube/
   when: result is failed
 
-- name: copy kubeconfig
+- name: "INSTALL: copy kubeconfig"
   shell:
     cmd: cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
   when: result is failed
index f6e7eac..22746d8 100644 (file)
@@ -14,7 +14,9 @@
 
 ---
 - include: "install.yml"
+  static: false
   when: operation == 'install'
 
 - include: "uninstall.yml"
+  static: false
   when: operation == 'uninstall'
index 31dbfc7..d58b1bb 100644 (file)
 # limitations under the License.
 
 ---
-- name: kill k3s
+- name: check whether k3s is already installed
+  shell:
+    cmd: which k3s
+  register: result
+  ignore_errors: yes
+  no_log: True
+
+- debug:
+    msg: Uninstalling k3s...
+  when: result.stdout != ""
+
+- debug:
+    msg: "UNINSTALL: Ignore Uninstall Log , K3s not installed"
+  when: result.stdout == ""
+
+- name: "UNINSTALL: kill k3s"
   shell:
     cmd: k3s-killall.sh
   when: result is succeeded
 
-- name: uninstall k3s
+- name: "UNINSTALL: uninstall k3s"
   shell:
     cmd: k3s-uninstall.sh
   when: result is succeeded
index 316542a..227d603 100644 (file)
@@ -15,6 +15,7 @@
 ---
 # tasks file for k8s
 - include: "install.yml"
+  static: false
   when: operation == 'install'
 
 #- include: "uninstall.yml"
index be458fd..f8472b4 100644 (file)
 # yamllint disable rule:line-length
   when: result.stdout == ""
 
-- name: Install prometheus on x86_64
+- name: "INSTALL: Install prometheus on x86_64"
   shell:
     cmd: helm install mep-prometheus stable/prometheus --version v9.3.1
   when: result is failed and ansible_architecture == 'x86_64'
 
-- name: copy values.yaml to host
+- name: "INSTALL: copy values.yaml to host"
   copy:
     src: values.yaml
     dest: /tmp/prometheus/
   when: result is failed and ansible_architecture == 'aarch64'
 
-- name: Install prometheus on aarch64
+- name: "INSTALL: Install prometheus on aarch64"
   shell:
     cmd: 'helm install mep-prometheus
     stable/prometheus -f /tmp/prometheus/values.yaml --version v9.3.1'
index f6e7eac..7daf37b 100644 (file)
@@ -14,7 +14,9 @@
 
 ---
 - include: "install.yml"
+  static: false
   when: operation == 'install'
 
-- include: "uninstall.yml"
-  when: operation == 'uninstall'
+  #- include: "uninstall.yml"
+  #static: false
+  #when: operation == 'uninstall'
index d6fe987..5edeed7 100644 (file)
 # yamllint disable rule:line-length
   when: result.stdout == ""
 
-- name: copy common folder to host for rabbitmg installation
+- name: "INSTALL: copy common folder to host for rabbitmg installation"
   copy:
     src: common
     dest: /tmp/rabbitmq/
   when: result is failed
 
-- name: Install common for rabbitmg installation
+- name: "INSTALL: Install common for rabbitmg installation"
   shell:
     cmd: kubectl apply -f /tmp/rabbitmq/common
   when: result is failed
 
-- name: copy statefulset_x86.yaml to host for rabbitmg installation
+- name: "INSTALL: copy statefulset_x86.yaml to host for rabbitmg installation"
   copy:
     src: statefulset_x86.yaml
     dest: /tmp/rabbitmq/
   when: result is failed and ansible_architecture == 'x86_64'
 
-- name: Install rabbitmq on x86_64
+- name: "INSTALL: Install rabbitmq on x86_64"
   shell:
     cmd: kubectl apply -f /tmp/rabbitmq/statefulset_x86.yaml
   when: result is failed and ansible_architecture == 'x86_64'
 
-- name: copy statefulset_arm.yaml to host for rabbitmg installation
+- name: "INSTALL: copy statefulset_arm.yaml to host for rabbitmg installation"
   copy:
     src: statefulset_arm.yaml
     dest: /tmp/rabbitmq/
   when: result is failed and ansible_architecture == 'aarch64'
 
-- name: Install rabbitmq on aarch64
+- name: "INSTALL: Install rabbitmq on aarch64"
   shell:
     cmd: kubectl apply -f /tmp/rabbitmq/statefulset_arm.yaml
   when: result is failed and ansible_architecture == 'aarch64'
index f6e7eac..7daf37b 100644 (file)
@@ -14,7 +14,9 @@
 
 ---
 - include: "install.yml"
+  static: false
   when: operation == 'install'
 
-- include: "uninstall.yml"
-  when: operation == 'uninstall'
+  #- include: "uninstall.yml"
+  #static: false
+  #when: operation == 'uninstall'