---

- name: Add repository locally
  local_action:
    module: kubernetes.core.helm_repository
    name: "{{ item.name }}"
    repo_url: "{{ item.repo_url }}"
  loop: "{{ helm.repos }}"

- name: Add repository to cluster
  kubernetes.core.helm_repository:
    name: "{{ item.name }}"
    repo_url: "{{ item.repo_url }}"
  loop: "{{ helm.repos }}"
  become: true

- name: Separately update the repository cache
  kubernetes.core.helm:
    kubeconfig_path: "/etc/rancher/k3s/k3s.yaml"
    name: dummy
    namespace: kube-system
    state: absent
    update_repo_cache: true
  become: true
