Added pre installation and unindtallation 89/3489/4
authorArvind Patel <arvind.patel@huawei.com>
Tue, 19 May 2020 13:25:00 +0000 (18:55 +0530)
committerGaurav Agrawal <gaurav.agrawal@huawei.com>
Tue, 19 May 2020 18:01:45 +0000 (18:01 +0000)
Change-Id: I883f3f97c2ac76471fe6fb1be48cc1fac2e26435

ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml
ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml
ocd/infra/playbooks/roles/grafana/tasks/install.yml
ocd/infra/playbooks/roles/grafana/tasks/uninstall.yml
ocd/infra/playbooks/roles/k3s/tasks/install.yml
ocd/infra/playbooks/roles/k3s/tasks/uninstall.yml
ocd/infra/playbooks/roles/k8s/tasks/install.yml
ocd/infra/playbooks/roles/prometheus/tasks/install.yml
ocd/infra/playbooks/roles/prometheus/tasks/uninstall.yml
ocd/infra/playbooks/roles/rabbitmq/tasks/install.yml
ocd/infra/playbooks/roles/rabbitmq/tasks/uninstall.yml

index f46bcd1..8c49f6a 100644 (file)
   shell:
     cmd: helm status cadvisor
   register: result
-  ignore_errors: 'True'
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: cAdvisor is already present
+  when: result.rc == 0
+
+- meta: end_play
+  when: result.rc == 0
 
 - name: "Add helm repo"
   command: helm repo add code-chris https://code-chris.github.io/helm-charts
index 8a01e80..53a7e62 100644 (file)
   shell:
     cmd: helm status cadvisor
   register: result
-  ignore_errors: 'True'
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: cAdvisor is not present
+  when: result.rc == 2
+
+- meta: end_play
+  when: result.rc == 2
 
 - name: "If cAdvisor present, then list helm ls"
   command: helm ls
index 93a392c..7efd8a6 100644 (file)
   shell:
     cmd: helm status mec-grafana
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: Grafana is already present
+  when: result.rc == 0
+
+- meta: end_play
+  when: result.rc == 0
 
 - name: Install grafana on x86_64
   shell:
index 8d76776..d95f346 100644 (file)
   shell:
     cmd: helm status mec-grafana
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: grafana is not present
+  when: result.rc == 2
+
+- meta: end_play
+  when: result.rc == 2
 
 - name: Uninstall grafana
   shell:
index a9968c3..e7a133b 100644 (file)
   shell:
     cmd: which k3s
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: k3s is already present
+  when: result.rc == 0
+
+- meta: end_play
+  when: result.rc == 0
 
 - debug: var=ansible_host
 
index 26d30c1..e5f16cc 100644 (file)
   shell:
     cmd: which k3s
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: k3s is not present
+  when: result.rc == 2
+
+- meta: end_play
+  when: result.rc == 2
 
 - name: kill k3s
   shell:
index 52466ab..62f1a84 100644 (file)
 
 ---
 # tasks file for k8s
-- name: debug msg
-  debug:
-    msg: installing k8s
+- name: Check whether k8s is already installed
+  command: which k8s
+  register: result
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: k8s is already present
+  when: result.rc == 0
+
+- meta: end_play
+  when: result.rc == 0
 
 - name: Install k8s
   shell:
index 29afd24..b5a2722 100644 (file)
   shell:
     cmd: helm status mep-prometheus
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: Prpmetheus is already present
+  when: result.rc == 0
+
+- meta: end_play
+  when: result.rc == 0
 
 - name: Install prometheus on x86_64
   shell:
index c4b7876..40aca5c 100644 (file)
   shell:
     cmd: helm status mep-prometheus
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: Prometheus is not present
+  when: result.rc == 2
+
+- meta: end_play
+  when: result.rc == 2
 
 - name: Uninstall prometheus
   shell:
index 757b616..6960ddd 100644 (file)
   shell:
     cmd: kubectl get pods rabbitmq-0
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: Rabbitmq is already present
+  when: result.rc == 0
+
+- meta: end_play
+  when: result.rc == 0
 
 - name: copy common folder to host for rabbitmg installation
   copy:
index 753aea5..c32f55f 100644 (file)
   shell:
     cmd: kubectl get pods rabbitmq-0
   register: result
-  ignore_errors: true
+  failed_when: false
+  no_log: True
+
+- debug:
+    msg: Rabbitmq is not present
+  when: result.rc == 2
+
+- meta: end_play
+  when: result.rc == 2
 
 - name: Uninstalling rabbitmq
   shell: