From b799151f59de0ff7cbf90fe3e653ef9a7bfaed10 Mon Sep 17 00:00:00 2001 From: Arvind Patel Date: Tue, 19 May 2020 18:55:00 +0530 Subject: [PATCH] Added pre installation and unindtallation Change-Id: I883f3f97c2ac76471fe6fb1be48cc1fac2e26435 --- ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml | 10 +++++++++- ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml | 10 +++++++++- ocd/infra/playbooks/roles/grafana/tasks/install.yml | 10 +++++++++- ocd/infra/playbooks/roles/grafana/tasks/uninstall.yml | 10 +++++++++- ocd/infra/playbooks/roles/k3s/tasks/install.yml | 10 +++++++++- ocd/infra/playbooks/roles/k3s/tasks/uninstall.yml | 10 +++++++++- ocd/infra/playbooks/roles/k8s/tasks/install.yml | 15 ++++++++++++--- ocd/infra/playbooks/roles/prometheus/tasks/install.yml | 10 +++++++++- ocd/infra/playbooks/roles/prometheus/tasks/uninstall.yml | 10 +++++++++- ocd/infra/playbooks/roles/rabbitmq/tasks/install.yml | 10 +++++++++- ocd/infra/playbooks/roles/rabbitmq/tasks/uninstall.yml | 10 +++++++++- 11 files changed, 102 insertions(+), 13 deletions(-) diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml b/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml index f46bcd1..8c49f6a 100644 --- a/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml +++ b/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml @@ -17,7 +17,15 @@ 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 diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml b/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml index 8a01e80..53a7e62 100644 --- a/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml +++ b/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml @@ -18,7 +18,15 @@ 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 diff --git a/ocd/infra/playbooks/roles/grafana/tasks/install.yml b/ocd/infra/playbooks/roles/grafana/tasks/install.yml index 93a392c..7efd8a6 100644 --- a/ocd/infra/playbooks/roles/grafana/tasks/install.yml +++ b/ocd/infra/playbooks/roles/grafana/tasks/install.yml @@ -17,7 +17,15 @@ 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: diff --git a/ocd/infra/playbooks/roles/grafana/tasks/uninstall.yml b/ocd/infra/playbooks/roles/grafana/tasks/uninstall.yml index 8d76776..d95f346 100644 --- a/ocd/infra/playbooks/roles/grafana/tasks/uninstall.yml +++ b/ocd/infra/playbooks/roles/grafana/tasks/uninstall.yml @@ -17,7 +17,15 @@ 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: diff --git a/ocd/infra/playbooks/roles/k3s/tasks/install.yml b/ocd/infra/playbooks/roles/k3s/tasks/install.yml index a9968c3..e7a133b 100644 --- a/ocd/infra/playbooks/roles/k3s/tasks/install.yml +++ b/ocd/infra/playbooks/roles/k3s/tasks/install.yml @@ -17,7 +17,15 @@ 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 diff --git a/ocd/infra/playbooks/roles/k3s/tasks/uninstall.yml b/ocd/infra/playbooks/roles/k3s/tasks/uninstall.yml index 26d30c1..e5f16cc 100644 --- a/ocd/infra/playbooks/roles/k3s/tasks/uninstall.yml +++ b/ocd/infra/playbooks/roles/k3s/tasks/uninstall.yml @@ -17,7 +17,15 @@ 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: diff --git a/ocd/infra/playbooks/roles/k8s/tasks/install.yml b/ocd/infra/playbooks/roles/k8s/tasks/install.yml index 52466ab..62f1a84 100644 --- a/ocd/infra/playbooks/roles/k8s/tasks/install.yml +++ b/ocd/infra/playbooks/roles/k8s/tasks/install.yml @@ -14,9 +14,18 @@ --- # 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: diff --git a/ocd/infra/playbooks/roles/prometheus/tasks/install.yml b/ocd/infra/playbooks/roles/prometheus/tasks/install.yml index 29afd24..b5a2722 100644 --- a/ocd/infra/playbooks/roles/prometheus/tasks/install.yml +++ b/ocd/infra/playbooks/roles/prometheus/tasks/install.yml @@ -17,7 +17,15 @@ 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: diff --git a/ocd/infra/playbooks/roles/prometheus/tasks/uninstall.yml b/ocd/infra/playbooks/roles/prometheus/tasks/uninstall.yml index c4b7876..40aca5c 100644 --- a/ocd/infra/playbooks/roles/prometheus/tasks/uninstall.yml +++ b/ocd/infra/playbooks/roles/prometheus/tasks/uninstall.yml @@ -17,7 +17,15 @@ 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: diff --git a/ocd/infra/playbooks/roles/rabbitmq/tasks/install.yml b/ocd/infra/playbooks/roles/rabbitmq/tasks/install.yml index 757b616..6960ddd 100644 --- a/ocd/infra/playbooks/roles/rabbitmq/tasks/install.yml +++ b/ocd/infra/playbooks/roles/rabbitmq/tasks/install.yml @@ -17,7 +17,15 @@ 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: diff --git a/ocd/infra/playbooks/roles/rabbitmq/tasks/uninstall.yml b/ocd/infra/playbooks/roles/rabbitmq/tasks/uninstall.yml index 753aea5..c32f55f 100644 --- a/ocd/infra/playbooks/roles/rabbitmq/tasks/uninstall.yml +++ b/ocd/infra/playbooks/roles/rabbitmq/tasks/uninstall.yml @@ -17,7 +17,15 @@ 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: -- 2.16.6