2018-10-21 11:58:25 +02:00
---
2019-01-08 09:19:45 +01:00
# This requires the dnspython library and will fail with a friendly error when unavailable.
2018-10-21 11:58:25 +02:00
- name : Check DNS SRV record
2019-01-08 09:19:45 +01:00
set_fact :
result_dig_srv : "{{ lookup('dig', ('_matrix._tcp.' + hostname_identity + './SRV'), 'flat=0', wantlist=False) }}"
2018-10-21 11:58:25 +02:00
2019-01-08 09:19:45 +01:00
- name : Fail if DNS SRV record missing
2018-10-21 11:58:25 +02:00
fail :
2019-01-08 09:19:45 +01:00
msg : "It appears the DNS SRV record for {{ hostname_identity }} is not set up correctly (the record is missing). See the 'Configuring DNS' documentation for this playbook."
when : "result_dig_srv == 'NXDOMAIN'"
2018-10-21 11:58:25 +02:00
- name : Fail if DNS SRV record incorrect
fail :
2019-01-08 09:19:45 +01:00
msg : >
It appears the DNS SRV record for {{ hostname_identity }} is not set up correctly.
Expected it to point to `{{ (hostname_matrix + '.') }}` (port 8448).
Found it pointing to `{{ result_dig_srv.target }}` (port {{ result_dig_srv.port }}).
See the 'Configuring DNS' documentation for this playbook.
when : "result_dig_srv.target != (hostname_matrix + '.') or result_dig_srv.port != 8448"
2018-10-21 11:58:25 +02:00
- name : Report correct DNS SRV record
debug :
msg : "The DNS SRV record for {{ hostname_identity }} points to {{ hostname_matrix }}, as expected"