diff --git a/ansible/roles/public_dns/tasks/create-cloudflare.yml b/ansible/roles/public_dns/tasks/create-cloudflare.yml index 1099c420..52f6e7bf 100644 --- a/ansible/roles/public_dns/tasks/create-cloudflare.yml +++ b/ansible/roles/public_dns/tasks/create-cloudflare.yml @@ -1,6 +1,6 @@ --- - name: Create Cloudflare DNS records via account_api_token - cloudflare_dns: + community.general.cloudflare_dns: zone: "{{ pd_cloudflare_zone }}" record: "{{ item }}.{{ pd_public_domain }}" # 1 is auto @@ -22,7 +22,7 @@ - name: Create IPv6 Cloudflare DNS records via account_api_token - cloudflare_dns: + community.general.cloudflare_dns: zone: "{{ pd_cloudflare_zone }}" record: "{{ item }}.{{ pd_public_domain }}" # 1 is auto @@ -43,7 +43,7 @@ - cloudflare_account_api_token is defined - name: Create Cloudflare DNS records via api_token - cloudflare_dns: + community.general.cloudflare_dns: zone: "{{ pd_cloudflare_zone }}" record: "{{ item }}.{{ pd_public_domain }}" # 1 is auto @@ -62,7 +62,7 @@ - cloudflare_api_token is defined - name: Create IPv6 Cloudflare DNS records via api_token - cloudflare_dns: + community.general.cloudflare_dns: zone: "{{ pd_cloudflare_zone }}" record: "{{ item }}.{{ pd_public_domain }}" # 1 is auto diff --git a/ansible/roles/public_dns/tasks/destroy-cloudflare.yml b/ansible/roles/public_dns/tasks/destroy-cloudflare.yml index 390c8dc2..08711c55 100644 --- a/ansible/roles/public_dns/tasks/destroy-cloudflare.yml +++ b/ansible/roles/public_dns/tasks/destroy-cloudflare.yml @@ -1,7 +1,6 @@ --- - - name: Delete DNS record at CloudFlare via account_api_token - cloudflare_dns: + community.general.cloudflare_dns: state: absent zone: "{{ pd_cloudflare_zone }}" record: "{{ item }}.{{ pd_public_domain }}" @@ -14,9 +13,12 @@ with_items: - api - '*.apps' + when: + - cloudflare_account_email is defined + - cloudflare_account_api_token is defined - name: Delete IPv6 DNS record at CloudFlare via account_api_token - cloudflare_dns: + community.general.cloudflare_dns: state: absent zone: "{{ pd_cloudflare_zone }}" record: "{{ item }}.{{ pd_public_domain }}" @@ -29,4 +31,39 @@ with_items: - api - '*.apps' - when: (pd_public_ipv6 is defined) and (pd_public_ipv6|length > 0) + when: + - cloudflare_account_email is defined + - cloudflare_account_api_token is defined + +- name: Delete DNS record at CloudFlare via api_token + community.general.cloudflare_dns: + state: absent + zone: "{{ pd_cloudflare_zone }}" + record: "{{ item }}.{{ pd_public_domain }}" + # 1 is auto + ttl: 1 + type: A + value: "{{ pd_public_ip }}" + api_token: "{{ cloudflare_api_token }}" + with_items: + - api + - '*.apps' + when: + - cloudflare_api_token is defined + +- name: Delete IPv6 DNS record at CloudFlare via api_token + community.general.cloudflare_dns: + state: absent + zone: "{{ pd_cloudflare_zone }}" + record: "{{ item }}.{{ pd_public_domain }}" + # 1 is auto + ttl: 1 + type: AAAA + value: "{{ pd_public_ipv6 }}" + api_token: "{{ cloudflare_api_token }}" + with_items: + - api + - '*.apps' + when: + - cloudflare_api_token is defined +