All checks were successful
continuous-integration/drone/push Build is passing
105 lines
2.9 KiB
YAML
105 lines
2.9 KiB
YAML
# - debug: var=my_context
|
|
# tags: monitoring
|
|
|
|
- name: monitoring setup
|
|
block:
|
|
- name: Include vars files list
|
|
ansible.builtin.include_vars: "{{ item }}"
|
|
with_items:
|
|
- "prometheus_files_list.yml"
|
|
- "grafana_files_list.yml"
|
|
|
|
- name: Find state of monitoring stack
|
|
ansible.builtin.set_fact:
|
|
monitoring_state: absent
|
|
when:
|
|
- prometheus_state == "absent"
|
|
- grafana_state == "absent"
|
|
|
|
- name: namespace
|
|
kubernetes.core.k8s:
|
|
state: "{{ monitoring_state }}"
|
|
context: "{{ my_context }}"
|
|
name: "{{ monitoring_namespace }}"
|
|
api_version: v1
|
|
kind: Namespace
|
|
when:
|
|
- monitoring_state == "present"
|
|
|
|
# - name: Create a Secret object for basic authentification
|
|
# kubernetes.core.k8s:
|
|
# state: "{{ prometheus_state }}"
|
|
# context: "{{ my_context }}"
|
|
# definition:
|
|
# apiVersion: v1
|
|
# kind: Secret
|
|
# metadata:
|
|
# name: basic-auth
|
|
# namespace: "{{ monitoring_namespace }}"
|
|
# type: Opaque
|
|
# data:
|
|
# basic_auth: "{{ basic_auth_data | b64encode }}"
|
|
# when:
|
|
# - basic_auth == true
|
|
# tags: prom
|
|
|
|
- name: Install Prometheus files
|
|
kubernetes.core.k8s:
|
|
state: "present"
|
|
context: "{{ my_context }}"
|
|
merge_type: merge
|
|
resource_definition: "{{ lookup('template', item) | from_yaml }}"
|
|
with_items:
|
|
- "{{ prometheus_files }}"
|
|
when:
|
|
- prometheus_state == "present"
|
|
tags: prometheus
|
|
|
|
- name: UnInstall Prometheus files
|
|
kubernetes.core.k8s:
|
|
state: "absent"
|
|
context: "{{ my_context }}"
|
|
merge_type: merge
|
|
resource_definition: "{{ lookup('template', item) | from_yaml }}"
|
|
with_items:
|
|
- "{{ prometheus_files | reverse | list }}"
|
|
when:
|
|
- prometheus_state == "absent"
|
|
tags: prometheus
|
|
|
|
- name: Install Grafana files
|
|
kubernetes.core.k8s:
|
|
state: "present"
|
|
context: "{{ my_context }}"
|
|
merge_type: merge
|
|
resource_definition: "{{ lookup('template', item) | from_yaml }}"
|
|
with_items:
|
|
- "{{ grafana_files }}"
|
|
when:
|
|
- grafana_state == "present"
|
|
tags: grafana
|
|
|
|
- name: UnInstall Grafana files
|
|
kubernetes.core.k8s:
|
|
state: "absent"
|
|
context: "{{ my_context }}"
|
|
merge_type: merge
|
|
resource_definition: "{{ lookup('template', item) | from_yaml }}"
|
|
with_items:
|
|
- "{{ grafana_files | reverse | list }}"
|
|
when:
|
|
- grafana_state == "absent"
|
|
tags: grafana
|
|
|
|
- name: namespace
|
|
kubernetes.core.k8s:
|
|
state: "{{ monitoring_state }}"
|
|
context: "{{ my_context }}"
|
|
name: "{{ monitoring_namespace }}"
|
|
api_version: v1
|
|
kind: Namespace
|
|
when:
|
|
- monitoring_state == "absent"
|
|
|
|
tags:
|
|
- monitoring
|