Add task to fail if full_domain already exists

This commit is contained in:
Adw8 2024-10-15 16:03:36 +05:30
parent ebe6a3cbd7
commit 8fbbbbdd7f

View File

@ -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