Make 2 block for install & uninstall of longhorn
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adrien Reslinger 2020-12-03 22:59:37 +01:00
parent ddb9600a9d
commit 535e80804b

View file

@ -2,48 +2,47 @@
- name: Include file list
include_vars: "longhorn.yaml"
- name: Defined longhorn state to present
set_fact:
storage_longhorn_state: present
when:
- storage_longhorn|bool
- name: Define state of longhorn to absent
set_fact:
storage_longhorn_state: absent
when:
- not storage_longhorn|bool
- name: longhorn need to be present
k8s:
state: present
context: "{{ my_context }}"
merge_type: merge
namespace: longhorn-system
resource_definition: "{{ lookup('file', 'longhorn/' + item) | from_yaml }}"
with_items:
- "{{ storage_longhorn_files_list }}"
block:
- name: Install files
k8s:
state: present
context: "{{ my_context }}"
merge_type: merge
namespace: longhorn-system
resource_definition: "{{ lookup('file', 'longhorn/' + item) | from_yaml }}"
with_items:
- "{{ storage_longhorn_files_list }}"
- name: Install Ingress for longhorn UI
k8s:
state: present
context: "{{ my_context }}"
merge_type: merge
namespace: longhorn-system
resource_definition: "{{ lookup('template', 'longhorn/' + item) | from_yaml }}"
with_items:
- "longhorn_ingressroute.yaml.j2"
when:
- storage_longhorn|bool
- name: longhorn need to be absent
k8s:
state: absent
context: "{{ my_context }}"
merge_type: merge
namespace: longhorn-system
resource_definition: "{{ lookup('file', 'longhorn/' + item) | from_yaml }}"
with_items:
- "{{ storage_longhorn_files_list | reverse | list }}"
block:
- name: Remove Ingress for longhorn UI
k8s:
state: absent
context: "{{ my_context }}"
namespace: longhorn-system
resource_definition: "{{ lookup('template', 'longhorn/' + item) | from_yaml }}"
with_items:
- "longhorn_ingressroute.yaml.j2"
- name: Remove files
k8s:
state: absent
context: "{{ my_context }}"
merge_type: merge
namespace: longhorn-system
resource_definition: "{{ lookup('file', 'longhorn/' + item) | from_yaml }}"
with_items:
- "{{ storage_longhorn_files_list | reverse | list }}"
when:
- not storage_longhorn|bool
- name: Ingress for longhorn UI need to be {{ storage_longhorn_state }}
k8s:
state: "{{ storage_longhorn_state }}"
context: "{{ my_context }}"
merge_type: merge
namespace: longhorn-system
resource_definition: "{{ lookup('template', 'longhorn/' + item) | from_yaml }}"
with_items:
- "longhorn_ingressroute.yaml.j2"