Skip to content

Commit

Permalink
bind_record - remove bad MX-validation (fix #105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Oct 7, 2024
1 parent 3682a87 commit c569d25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 0 additions & 2 deletions plugins/module_utils/main/bind_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def check(self) -> None:
self.m.fail_json(f"Value '{self.p['value']}' is not a valid IPv4-address!")
elif self.p['type'] == 'AAAA' and not is_ip6(self.p['value']):
self.m.fail_json(f"Value '{self.p['value']}' is not a valid IPv6-address!")
elif self.p['type'] == 'MX' and not valid_hostname(self.p['value']):
self.m.fail_json(f"Value '{self.p['value']}' is not a valid hostname!")

# custom matching as dns round-robin allows for multiple records to match..
if self.existing_entries is None:
Expand Down
15 changes: 13 additions & 2 deletions tests/bind_record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
- {t: 'A', v: '2001:db8::1'}
- {t: 'AAAA', v: 'not-an-ip'}
- {t: 'AAAA', v: '192.168.0.1'}
- {t: 'MX', v: 'not-a-hostname'}
- {t: 'MX', v: '192.168.0.1'}

- name: Adding 1
ansibleguy.opnsense.bind_record:
Expand Down Expand Up @@ -217,6 +215,18 @@
failed_when: not opn14.failed
when: not ansible_check_mode

- name: Adding 4 (mx)
ansibleguy.opnsense.bind_record:
domain: 'test4.ansibleguy'
name: ''
type: 'MX'
value: '10 mx.test.ansibleguy.net.'
register: opn11
failed_when: >
opn11.failed or
not opn11.changed
when: not ansible_check_mode

- name: Cleanup
ansibleguy.opnsense.bind_record:
domain: 'test4.ansibleguy'
Expand All @@ -226,6 +236,7 @@
loop:
- {'n': 'test1'}
- {'n': 'test2', 't': 'TXT'}
- {'n': '', 't': 'MX'}
when: not ansible_check_mode

- name: Cleanup domain
Expand Down

0 comments on commit c569d25

Please sign in to comment.