Skip to content

Commit dfec83c

Browse files
avalor1Andreas Hering
andauthored
Fix azure dns challenge bug (#91)
* Trigger tests * Trigger more tests * Fix azure dns challenge bug Added condition to only try to do creation, removal of txt records if there is challenge data. This can happen if certificate is not due for renewal. --------- Co-authored-by: Andreas Hering <andreas.hering@t-systems.com>
1 parent e5b7b11 commit dfec83c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

roles/acme/tasks/challenge/dns-01/azure.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
records:
1212
- entry: "{{ challenge['challenge_data'][item]['dns-01']['resource_value'] }}"
1313
loop: "{{ acme_domain.subject_alt_name.top_level }}"
14-
when: acme_domain.subject_alt_name.top_level is defined
14+
when:
15+
- acme_domain.subject_alt_name.top_level is defined
16+
# only runs if the challenge is run the first time, because then there is challenge_data
17+
- challenge['challenge_data'][item] is defined
1518

1619
# split second_level for zone_name and if subdomain is defined add subdomain to relative_name
1720
- name: Add a new TXT record to the SAN second-level domains
@@ -25,7 +28,10 @@
2528
records:
2629
- entry: "{{ challenge['challenge_data'][item]['dns-01']['resource_value'] }}"
2730
loop: "{{ acme_domain.subject_alt_name.second_level }}"
28-
when: acme_domain.subject_alt_name.second_level is defined
31+
when:
32+
- acme_domain.subject_alt_name.second_level is defined
33+
# only runs if the challenge is run the first time, because then there is challenge_data
34+
- challenge['challenge_data'][item] is defined
2935

3036
- name: Let the challenge be validated and retrieve the cert and intermediate certificate
3137
community.crypto.acme_certificate:
@@ -54,7 +60,10 @@
5460
records:
5561
- entry: "{{ challenge['challenge_data'][item]['dns-01']['resource_value'] }}"
5662
loop: "{{ acme_domain.subject_alt_name.top_level }}"
57-
when: acme_domain.subject_alt_name.top_level is defined
63+
when:
64+
- acme_domain.subject_alt_name.top_level is defined
65+
# only runs if the challenge is run the first time, because then there is challenge_data
66+
- challenge['challenge_data'][item] is defined
5867

5968
- name: Remove created SAN second-level TXT records to keep DNS zone clean
6069
azure.azcollection.azure_rm_dnsrecordset:
@@ -67,4 +76,7 @@
6776
records:
6877
- entry: "{{ challenge['challenge_data'][item]['dns-01']['resource_value'] }}"
6978
loop: "{{ acme_domain.subject_alt_name.second_level }}"
70-
when: acme_domain.subject_alt_name.second_level is defined
79+
when:
80+
- acme_domain.subject_alt_name.second_level is defined
81+
# only runs if the challenge is run the first time, because then there is challenge_data
82+
- challenge['challenge_data'][item] is defined

0 commit comments

Comments
 (0)