---
- name: Kubeovn | Synchronize Kube-OVN Helm chart package to remote node
  copy:
    src: >-
      {{ .binary_dir }}/cni/kubeovn/kubeovn-{{ .cni.kubeovn_version }}.tgz
    dest: >-
      /etc/kubernetes/cni/kubeovn-{{ .cni.kubeovn_version }}.tgz

- name: Kubeovn | Generate Kube-OVN custom values file
  copy:
    content: |
      {{ .cni.kubeovn.values }}
    dest: /etc/kubernetes/cni/kubeovn-values.yaml

- name: Kubeovn | Add Kube-OVN labels to nodes
  command: |
    kubectl label node -lbeta.kubernetes.io/os=linux kubernetes.io/os=linux --overwrite
    kubectl label node -lnode-role.kubernetes.io/control-plane kube-ovn/role=master --overwrite

- name: Kubeovn | Install Kube-OVN using Helm with custom values
  command: |
    helm upgrade --install --namespace kubeovn-system kubeovn /etc/kubernetes/cni/kubeovn-{{ .cni.kubeovn_version }}.tgz -f /etc/kubernetes/cni/kubeovn-values.yaml

# Reference: https://kubeovn.github.io/docs/stable/start/one-step-install/#helm-chart
- name: Kubeovn | Install Kube-OVN using Helm
  command: |
    helm upgrade --install --namespace kubeovn-system kubeovn /etc/kubernetes/cni/kubeovn-{{ .cni.kubeovn_version }}.tgz 
