92 lines
2.9 KiB
YAML
92 lines
2.9 KiB
YAML
---
|
|
- name: longhorn need to be present
|
|
block:
|
|
- name: Defined longhorn repository
|
|
kubernetes.core.helm_repository:
|
|
name: longhorn
|
|
repo_url: "https://charts.longhorn.io"
|
|
- name: Deploy latest version of longhorn
|
|
kubernetes.core.helm:
|
|
context: "{{ my_context }}"
|
|
name: longhorn
|
|
chart_ref: longhorn/longhorn
|
|
chart_version: "{{ storage_longhorn_version }}"
|
|
create_namespace: true
|
|
release_namespace: "{{ storage_longhorn_namespace }}"
|
|
values: "{{ lookup('template', 'longhorn/longhorn-values.yaml.j2') | from_yaml }}"
|
|
|
|
- name: Configure Longhorn
|
|
kubernetes.core.k8s:
|
|
state: present
|
|
context: "{{ my_context }}"
|
|
definition:
|
|
kind: Setting
|
|
apiVersion: longhorn.io/v1beta1
|
|
metadata:
|
|
name: "{{ item.name }}"
|
|
namespace: "{{ storage_longhorn_namespace }}"
|
|
value: "{{ item.value }}"
|
|
with_items:
|
|
- { name: "guaranteed-engine-manager-cpu", value: "6" }
|
|
- { name: "guaranteed-replica-manager-cpu", value: "6" }
|
|
- { name: "default-data-locality", value: "best-effort" }
|
|
|
|
- name: Install longhorn Recurring Jobs
|
|
kubernetes.core.k8s:
|
|
state: present
|
|
context: "{{ my_context }}"
|
|
apply: true
|
|
namespace: "{{ storage_longhorn_namespace }}"
|
|
resource_definition: "{{ lookup('template', 'longhorn/longhorn_recurringjob.yml.j2') | from_yaml }}"
|
|
with_items:
|
|
- {
|
|
name: "snapshot",
|
|
ansible.builtin.cron: "1 * * * *",
|
|
task: "snapshot",
|
|
retain: 25
|
|
}
|
|
- {
|
|
name: "backup-daily",
|
|
ansible.builtin.cron: "0 1 * * *",
|
|
task: "backup",
|
|
retain: 8
|
|
}
|
|
|
|
# - name: Install longhorn UI Ingress
|
|
# kubernetes.core.k8s:
|
|
# state: present
|
|
# context: "{{ my_context }}"
|
|
# apply: true
|
|
# namespace: "{{ storage_longhorn_namespace }}"
|
|
# resource_definition: "{{ lookup('template', 'longhorn/' + item) | from_yaml }}"
|
|
# with_items:
|
|
# - "longhorn_ingressroute.yaml.j2"
|
|
when:
|
|
- storage_longhorn_enabled
|
|
tags:
|
|
- longhorn
|
|
- storage
|
|
|
|
- name: longhorn need to be absent
|
|
block:
|
|
- name: Deploy latest version of longhorn
|
|
kubernetes.core.helm:
|
|
context: "{{ my_context }}"
|
|
name: longhorn
|
|
state: absent
|
|
release_namespace: "{{ storage_longhorn_namespace }}"
|
|
|
|
- name: Remove Ingress for longhorn UI
|
|
kubernetes.core.k8s:
|
|
state: absent
|
|
context: "{{ my_context }}"
|
|
namespace: "{{ storage_longhorn_namespace }}"
|
|
resource_definition: "{{ lookup('template', 'longhorn/' + item) | from_yaml }}"
|
|
with_items:
|
|
# - "longhorn_ingressroute.yaml.j2"
|
|
- "longhorn-namespace.yml.j2"
|
|
when:
|
|
- not storage_longhorn_enabled
|
|
tags:
|
|
- longhorn
|
|
- storage
|