From e20d8ba804539203664a542521db5b64826ba05c Mon Sep 17 00:00:00 2001 From: adi0509 Date: Fri, 21 Aug 2020 23:24:08 +0530 Subject: LMA: Deployment of LMA solution.(ansible) Ansible playbooks for LMA deployment Signed-off-by: Adarsh Yadav Change-Id: I3ab71e139bc1668577506fb996105a834a9c3c65 --- .../roles/clean-logging/tasks/main.yml | 193 +++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 tools/lma/ansible-server/roles/clean-logging/tasks/main.yml (limited to 'tools/lma/ansible-server/roles/clean-logging/tasks') diff --git a/tools/lma/ansible-server/roles/clean-logging/tasks/main.yml b/tools/lma/ansible-server/roles/clean-logging/tasks/main.yml new file mode 100644 index 00000000..259065ed --- /dev/null +++ b/tools/lma/ansible-server/roles/clean-logging/tasks/main.yml @@ -0,0 +1,193 @@ +# Copyright 2020 Adarsh yadav +# +# 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. +--- +#Deleting EFK setup from k8s cluster + +#check kubelet is running or not +- name: check for kubelet + shell: "systemctl status kubelet" + register: _svc_kubelet + failed_when: _svc_kubelet.rc != 0 and ("could not be found" not in _svc_kubelet.stderr) + +#*********************************************************************************************************** +#copy all yaml to /tmp/files/ +#*********************************************************************************************************** +- name: copy all yaml to /tmp/files/ + copy: + src: ../../logging/files/ + dest: /tmp/files/ + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Stop elastalert +#*********************************************************************************************************** +- name: Delete elastalert config configmap + k8s: + state: absent + src: /tmp/files/elastalert/ealert-conf-cm.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete elastalert key configmap + k8s: + state: absent + src: /tmp/files/elastalert/ealert-key-cm.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete elastalert rule configmap + k8s: + state: absent + src: /tmp/files/elastalert/ealert-rule-cm.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete elastalert pod + k8s: + state: absent + src: /tmp/files/elastalert/elastalert.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Stop fluentd +#*********************************************************************************************************** + +- name: Delete fluentd service + k8s: + state: absent + src: /tmp/files/fluentd/fluent-service.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete fluentd configmap + k8s: + state: absent + src: /tmp/files/fluentd/fluent-cm.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete fluentd pod + k8s: + state: absent + src: /tmp/files/fluentd/fluent.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Stop nginx +#*********************************************************************************************************** +- name: Delete nginx service + k8s: + state: absent + src: /tmp/files/nginx/nginx-service.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete nginx configmap + k8s: + state: absent + src: /tmp/files/nginx/nginx-conf-cm.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete nginx key configmap + k8s: + state: absent + src: /tmp/files/nginx/nginx-key-cm.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +- name: Delete nginx pod + k8s: + state: absent + src: /tmp/files/nginx/nginx.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Stop Kibana +#*********************************************************************************************************** +- name: Stopping Kibana + k8s: + state: absent + src: /tmp/files/kibana/kibana.yaml + namespace: logging + ignore_errors: yes + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Stop Elasticsearch +#*********************************************************************************************************** +- name: Stopping Elasticsearch + k8s: + state: absent + src: /tmp/files/elasticsearch/elasticsearch.yaml + namespace: logging + ignore_errors: yes + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Stop Elasticsearch operator +#*********************************************************************************************************** +- name: Stopping Elasticsearch operator + shell: kubectl delete -f https://download.elastic.co/downloads/eck/1.2.0/all-in-one.yaml + ignore_errors: yes + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Delete Persistent Volume +#*********************************************************************************************************** +- name: Deleting Persistent Volume + k8s: + state: absent + src: /tmp/files/persistentVolume.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Delete Storage Class +#*********************************************************************************************************** +- name: Deleting Storage Class + k8s: + state: absent + src: /tmp/files/storageClass.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#IF KUBELET IS RUNNING, THEN +#Delete Namespace +#*********************************************************************************************************** +- name: Deleting Namespace + k8s: + state: absent + src: /tmp/files/namespace.yaml + namespace: logging + when: "_svc_kubelet.rc == 0" + +#*********************************************************************************************************** +#removing /tmp/files +#*********************************************************************************************************** +- name: Removing /tmp/files + file: + path: "/tmp/files" + state: absent -- cgit 1.2.3-korg