#- debug: var=my_context # tags: monitoring - name: monitoring setup block: - include_vars: "{{ item }}" with_items: - "prometheus_files_list.yml" - "grafana_files_list.yml" - name: Find state of monitoring stack set_fact: 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: Install Prometheus files 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 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 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 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 k8s: state: "{{ monitoring_state }}" context: "{{ my_context }}" name: "{{ monitoring_namespace }}" api_version: v1 kind: Namespace when: - monitoring_state == "absent" tags: - monitoring