summaryrefslogtreecommitdiff
path: root/roles/kubernetes/addons/openebs-zfs/tasks/main.yml
blob: d1c47ef52a258efde601fd07b12f52fd9b50c8ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
- name: deploy metrics-server addon
  run_once: true
  delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
  block:
  - name: create base directory for openebs-zfs addon
    file:
      path: /etc/kubernetes/addons/openebs-zfs
      state: directory

  - name: copy config for openebs-zfs
    template:
      src: "zfs-operator.{{ kubernetes_openebs_zfs_version }}.yml.j2"
      dest: /etc/kubernetes/addons/openebs-zfs/config.yml

  - name: check if openebs-zfs is already installed
    check_mode: no
    command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/openebs-zfs/config.yml
    failed_when: false
    changed_when: false
    register: kube_openebs_zfs_config_diff_result

  - name: install openebs-zfs onto the cluster
    when: kube_openebs_zfs_config_diff_result.rc != 0
    command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/openebs-zfs/config.yml


  - name: copy storageclasses config for openebs-zfs
    loop: "{{ kubernetes_openebs_zfs_storage_classes | dict2items }}"
    loop_control:
      label: "{{ item.key }}"
    template:
      src: "storageclass.yml.j2"
      dest: "/etc/kubernetes/addons/openebs-zfs/sc-{{ item.key }}.yml"

  - name: check if openebs-zfs storageclass already exists
    loop: "{{ kubernetes_openebs_zfs_storage_classes | list }}"
    check_mode: no
    command: "kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/openebs-zfs/sc-{{ item }}.yml"
    failed_when: false
    changed_when: false
    register: kube_openebs_zfs_sc_diff

  - name: install/update storageclasses for openebs-zfs
    loop: "{{ kube_openebs_zfs_sc_diff.results | selectattr('rc', 'ne', 0) | map(attribute='item') }}"
    command: "kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/openebs-zfs/sc-{{ item }}.yml"