matrix-docker-ansible-deploy/roles/matrix-server/tasks/self_check/self_check_dns.yml
Slavi Pantaleev f92c4d5a27 Use Ansible dig lookup instead of calling the dig program
This means we no longer have a dependency on the `dig` program,
but we do have a dependency on `dnspython`.

Improves things as suggested in #65 (Github issue).
2019-01-08 10:19:45 +02:00

24 lines
1.1 KiB
YAML

---
# This requires the dnspython library and will fail with a friendly error when unavailable.
- name: Check DNS SRV record
set_fact:
result_dig_srv: "{{ lookup('dig', ('_matrix._tcp.' + hostname_identity + './SRV'), 'flat=0', wantlist=False) }}"
- name: Fail if DNS SRV record missing
fail:
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'"
- name: Fail if DNS SRV record incorrect
fail:
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"
- name: Report correct DNS SRV record
debug:
msg: "The DNS SRV record for {{ hostname_identity }} points to {{ hostname_matrix }}, as expected"