ansible-role-k8s-monitoring/tasks/main.yml
2020-04-20 21:53:07 +02:00

76 lines
No EOL
1.9 KiB
YAML

#- debug: var=my_context
# tags: traefik
- name: traefik setup
block:
- include_vars: "{{ item }}"
with_items:
- "prometheus_files_list.yml"
- "grafana_files_list.yml"
- name: Find state of monitoring stack
set_facts:
monitoring_state: absent
when:
- prometheus_state == "absent"
- grafana_state == "absent"
- name: namespace
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
# 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: Prometheus files need to be {{ prometheus_state }}
k8s:
state: "{{ prometheus_state }}"
context: "{{ my_context }}"
merge_type: merge
resource_definition: "{{ lookup('template', item) | from_yaml }}"
with_items:
- "{{ prometheus_files }}"
tags: monitoring
- name: Grafana files need to be {{ grafana_state }}
k8s:
state: "{{ grafana_state }}"
context: "{{ my_context }}"
merge_type: merge
resource_definition: "{{ lookup('template', item) | from_yaml }}"
with_items:
- "{{ grafana_files }}"
tags: grafana
- name: namespace
k8s:
state: "{{ monitoring_state }}"
context: "{{ my_context }}"
name: "{{ monitoring_namespace }}"
api_version: v1
kind: Namespace
when:
- monitoring_state == "absent"
tags:
- monitoring