Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

66 lignes
3.7 KiB

  1. ---
  2. # This requires the dnspython library which is usually unavailable.
  3. - name: Check DNS SRV record for {{ dns_srv_record_check.service_and_protocol }} on {{ dns_srv_record_check.domain }} using Ansible dig lookup
  4. set_fact:
  5. lookup_dig_srv: "{{ lookup('dig', (dns_srv_record_check.service_and_protocol + '.' + dns_srv_record_check.domain + '/SRV'), 'flat=0', wantlist=False) }}"
  6. register: result_lookup_dig_srv
  7. ignore_errors: true
  8. - name: Fail if DNS SRV check via Ansible dig lookup failed for non-dependency reason
  9. fail:
  10. msg: "DNS SRV record check via Ansible dig lookup plugin (which uses the dnspython package) failed. Error is: {{ result_lookup_dig_srv.msg }}"
  11. when: "result_lookup_dig_srv.failed and 'dnspython' not in result_lookup_dig_srv.msg"
  12. # Fallback to using the dig CLI tool if dnspython was unavailable.
  13. - name: Check DNS SRV record for {{ dns_srv_record_check.service_and_protocol }} on {{ dns_srv_record_check.domain }} using dig CLI tool
  14. shell:
  15. cmd: "dig -t srv {{ (dns_srv_record_check.service_and_protocol + '.' + dns_srv_record_check.domain)|quote }}"
  16. register: result_cli_dig_srv
  17. changed_when: false
  18. ignore_errors: true
  19. when: "lookup_dig_srv is not defined"
  20. - name: Fail if dig CLI used and failed
  21. fail:
  22. msg: >-
  23. Failed performing DNS SRV record check.
  24. You neither have the `dnspython` Python package, nor the `dig` program installed locally.
  25. You need to install one of those, so we could perform a DNS SRV record check.
  26. Full error from trying to run `dig`: {{ result_cli_dig_srv }}
  27. when: "lookup_dig_srv is not defined and result_cli_dig_srv.stderr != ''"
  28. - name: Fail if DNS SRV record missing (Ansible dig lookup)
  29. fail:
  30. msg: >-
  31. It appears the DNS SRV record for {{ dns_srv_record_check.service_and_protocol }} on {{ dns_srv_record_check.domain }} is not set up correctly (the record is missing).
  32. See the 'Configuring DNS' documentation for this playbook.
  33. when: "lookup_dig_srv is defined and lookup_dig_srv == 'NXDOMAIN'"
  34. - name: Fail if DNS SRV record incorrect (Ansible dig lookup)
  35. fail:
  36. msg: >-
  37. It appears the DNS SRV record for {{ dns_srv_record_check.service_and_protocol }} on {{ dns_srv_record_check.domain }} is not set up correctly.
  38. Expected it to point to `{{ dns_srv_record_check.expected_target }}` (port {{ dns_srv_record_check.expected_port }}).
  39. Found it pointing to `{{ lookup_dig_srv.target }}` (port {{ lookup_dig_srv.port }}).
  40. See the 'Configuring DNS' documentation for this playbook.
  41. when: "lookup_dig_srv is defined and (lookup_dig_srv.target != dns_srv_record_check.expected_target or lookup_dig_srv.port != dns_srv_record_check.expected_port)"
  42. # We expect an answer like this:
  43. # ;; ANSWER SECTION:
  44. # _matrix._tcp.DOMAIN. 10800 IN SRV 10 0 8448 matrix.DOMAIN.
  45. - name: Fail if DNS SRV record missing or incorrect (dig CLI tool)
  46. fail:
  47. msg: >-
  48. It appears the DNS SRV record for {{ dns_srv_record_check.service_and_protocol }} on {{ dns_srv_record_check.domain }} is not set up correctly.
  49. Expected it to point to `{{ dns_srv_record_check.expected_target }}` (port {{ dns_srv_record_check.expected_port }}).
  50. See the 'Configuring DNS' documentation for this playbook.
  51. Full response from the `dig` lookup was: {{ result_cli_dig_srv }}
  52. when: "lookup_dig_srv is not defined and (dns_srv_record_check.expected_port|string + ' ' + dns_srv_record_check.expected_target) not in result_cli_dig_srv.stdout"
  53. - name: Report correct DNS SRV record
  54. debug:
  55. msg: >-
  56. The DNS SRV record for `{{ dns_srv_record_check.service_and_protocol }}` on `{{ dns_srv_record_check.domain }}`
  57. points to `{{ dns_srv_record_check.expected_target }}` (port {{ dns_srv_record_check.expected_port }}), as expected.