ansible-role-k8s-storage/tasks/longhorn.yml
Adrien 535e80804b
All checks were successful
continuous-integration/drone/push Build is passing
Make 2 block for install & uninstall of longhorn
2020-12-03 22:59:37 +01:00

48 lines
1.5 KiB
YAML

---
- name: Include file list
include_vars: "longhorn.yaml"
- name: longhorn need to be present
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
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