diff --git a/service-provider-setup/setup-dns.yml b/service-provider-setup/setup-dns.yml index fc46b44..3830dd5 100644 --- a/service-provider-setup/setup-dns.yml +++ b/service-provider-setup/setup-dns.yml @@ -6,6 +6,16 @@ - vars/k8s-vars.yml tasks: + - name: Check if domain exists + community.digitalocean.digital_ocean_domain_facts: + oauth_token: "{{ do_api_token }}" + register: existing_domains + + - name: Fail if domain already exists + fail: + msg: "Domain {{ full_domain }} already exists." + when: full_domain in existing_domains.data | map(attribute='name') | list + - name: Create a domain community.digitalocean.digital_ocean_domain: state: present