Add or remove without error

This commit is contained in:
Adrien Reslinger 2020-05-19 00:27:42 +02:00
parent b285f2f842
commit a0f6cb9c66

View file

@ -1,7 +1,7 @@
#- debug: var=my_context
# tags: traefik
# tags: monitoring
- name: traefik setup
- name: monitoring setup
block:
- include_vars: "{{ item }}"
with_items:
@ -42,24 +42,52 @@
# - basic_auth == true
# tags: prom
- name: Prometheus files need to be {{ prometheus_state }}
- name: Install Prometheus files
k8s:
state: "{{ prometheus_state }}"
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: Grafana files need to be {{ grafana_state }}
- name: UnInstall Prometheus files
k8s:
state: "{{ grafana_state }}"
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