- name: CertManager | Copy latest manifest
  ansible.builtin.get_url:
    url: "https://github.com/cert-manager/cert-manager/releases/download/v{{ microk8s_certmgr_version }}/cert-manager.yaml"
    dest: "{{ k8s_etc }}/k8s-certmanager.yaml"
    mode: "0600"

- name: CertManager | Apply manifest
  environment:
    PATH: "{{ k8s_venv }}/bin:{{ ansible_env.PATH }}"
  vars:
    ansible_python_interpreter: "{{ k8s_venv }}/bin/python"
  kubernetes.core.k8s:
    state: present
    kubeconfig: "{{ k8s_kubeconfig }}"
    src: "{{ k8s_etc }}/k8s-certmanager.yaml"
    wait: true

- name: CertManager | LetsEncrypt DNS-01 issuer
  ansible.builtin.include_tasks: issuers/dns-01.yml
  when: microk8s_certmgr_letsencrypt_dns01 is true

- name: CertManager | LetsEncrypt HTTP-01 issuer
  ansible.builtin.include_tasks: issuers/http-01.yml
  when: microk8s_certmgr_letsencrypt_http01 is true
