---

### tags:
###   csi

- name: Create secret for Hetzner CSI
  become: yes
  kubernetes.core.k8s:
    definition:
      api_version: v1
      kind: Secret
      metadata:
        namespace: kube-system
        name: hcloud-csi
        label:
          app: csi
          provider: hcloud
      type: Opaque
      data:
        token: "{{ hetzner_authentication_csi | string | b64encode }}"
  when:
    - inventory_hostname == groups['kube_control_plane'][0]
  tags:
    - csi

- name: Applying CSI deployment
  become: yes
  kubernetes.core.k8s:
    state: present
    definition: "{{ lookup('template', k8s_csi__template) }}"
  when:
    - inventory_hostname == groups['kube_control_plane'][0]
  tags:
    - csi
