---

### tags:
###   external-dns

- name: Install external-dns via helm
  become: yes
  kubernetes.core.helm:
    name: external-dns
    chart_ref: "{{ k8s_externaldns_helm__chart_ref }}"
    chart_repo_url: "{{ k8s_externaldns_helm__chart_repo_url }}"
    release_namespace: "{{ k8s_externaldns_helm__release_namespace }}"
    create_namespace: yes
    release_values: "{{ k8s_externaldns_helm__release_values }}"
  when:
  - inventory_hostname == groups['kube_control_plane'][0]
  tags:
    - external-dns

- name: Create secret for digitalocean-dns
  become: yes
  kubernetes.core.k8s:
    definition:
      api_version: v1
      kind: Secret
      metadata:
        namespace: "{{ k8s_externaldns_helm__release_namespace }}"
        name: digitalocean-dns
      type: Opaque
      data:
        access-token: "{{ digitalocean_authentication_token | string | b64encode }}"
  when: 
  - inventory_hostname == groups['kube_control_plane'][0]
  tags:
    - external-dns
