---
- ansible.builtin.import_tasks: dns-plugin-install.yml
  when: certbot_dns_plugin is defined

- ansible.builtin.import_tasks: prepare-certbot-for-dns.yml
  when: certbot_dns_plugin is defined

- name: Delete Certificates.
  ansible.builtin.include_tasks: delete-cert.yml
  with_items: "{{ certbot_certs }}"
  when:
    - certbot_delete_certs|bool
  loop_control:
    loop_var: cert_item

- name: Certbot Create Certificates.
  ansible.builtin.import_role:
    name: certbot
  when:
    - certbot_create_if_missing

# Same cron name from: geerlingguy.certbot
- name: Remove cron job for certbot renewal (if configured).
  ansible.builtin.cron:
    name: Certbot automatic renewal.
    state: absent
  when:
    - not certbot_auto_renew
