From 8fbbbbdd7f33633d2d55804f582a2ce4eb766dfd Mon Sep 17 00:00:00 2001 From: Adw8 Date: Tue, 15 Oct 2024 16:03:36 +0530 Subject: [PATCH] Add task to fail if full_domain already exists --- service-provider-setup/setup-dns.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) 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