Skip to content

Commit

Permalink
1.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
markuman committed Apr 22, 2021
1 parent c3277ce commit 8221c80
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 1.4.3

* fix bug. `purge: yes` removes not all existing records

# 1.4.2

* fix bug. even with `purge: yes`, it was always handled as `purge: no` and was always appending values.
* https://git.osuv.de/m/hetzner_dns/commit/c57e5fd8b9a2a9ad8a9a3769a1f98e9664e0e685

# 1.4.1

* minor change (_documentation update_).
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace: "markuman"
description: hetzner dns collection
name: "hetzner_dns"
version: "1.4.2"
version: "1.4.3"
readme: "README.md"
authors:
- "Markus Bergholz <[email protected]>"
Expand Down
8 changes: 6 additions & 2 deletions plugins/modules/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,17 @@ def main():
else:
this_record = { 'record': record }


if record_changed and not purge:
record_exists = False
record_changed = False

if state == 'present':
if not record_exists:
if purge and len(record_ids) > 1:
for id in record_ids:
r = dns.delete_record(id)

if not record_exists or (purge and len(record_ids) > 1):
record_id = None
this_record = { 'record': future_record }
change = True
Expand All @@ -146,7 +151,6 @@ def main():
if not module.check_mode:
r = dns.update_record(future_record, record_id)
this_record = r.json()


if state == 'absent':
if record_exists:
Expand Down
67 changes: 65 additions & 2 deletions tests/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
type: CNAME
ttl: 300
register: RECORD

- name: assert add record no change
assert:
that:
Expand Down Expand Up @@ -253,7 +253,7 @@
zone_name: "{{ TEST_ZONE }}"
register: RECORD

- name: assert 2 A recordds
- name: assert 0 A records
assert:
that:
- RECORD.record_info | count == 0
Expand Down Expand Up @@ -290,6 +290,69 @@
- RECORD.record_info[0].type == 'A'
- RECORD.record_info[0].value == '127.0.0.2'

- name: append record website1
markuman.hetzner_dns.record:
zone_name: osuv.de
name: website1
type: A
purge: no
value: 127.0.0.1

- name: fetch record info
markuman.hetzner_dns.record_info:
filter:
- name: website1
type: A
zone_name: osuv.de
register: RECORD

- name: assert 2 A record
assert:
that:
- RECORD.record_info | count == 2

- name: replace all
markuman.hetzner_dns.record:
zone_name: osuv.de
name: website1
type: A
purge: yes
value: 8.8.8.8

- name: fetch record info
markuman.hetzner_dns.record_info:
filter:
- name: website1
type: A
zone_name: osuv.de
register: RECORD

- name: assert 1 A record
assert:
that:
- RECORD.record_info | count == 1

- name: remove all records website1
markuman.hetzner_dns.record:
zone_name: osuv.de
name: website1
type: A
purge: yes
state: absent

- name: fetch record info
markuman.hetzner_dns.record_info:
filter:
- name: website1
type: A
zone_name: osuv.de
register: RECORD

- name: assert 0 A records
assert:
that:
- RECORD.record_info | count == 0

always:
- name: always del CNAME record
markuman.hetzner_dns.record:
Expand Down

0 comments on commit 8221c80

Please sign in to comment.