generate-dns.yml 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ---
  2. - name: "Generate list of private A records"
  3. set_fact:
  4. private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[item]['ansible_hostname'] + openshift_openstack_private_hostname_suffix + '.' + openshift_openstack_full_dns_domain, 'ip': hostvars[item]['private_v4'] } ] }}"
  5. with_items: "{{ groups['cluster_hosts'] }}"
  6. - name: "Add wildcard records to the private A records for infrahosts"
  7. set_fact:
  8. private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': '*.' + hostvars[groups.masters[0]].openshift_master_default_subdomain, 'ip': hostvars[item]['private_v4'] } ] }}"
  9. with_items: "{{ groups['infra_hosts'] }}"
  10. when: openshift_openstack_public_router_ip is defined
  11. - name: "Add public master cluster hostname records to the private A records (single master)"
  12. set_fact:
  13. private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[groups.masters[0]].openshift_master_cluster_public_hostname, 'ip': hostvars[groups.masters[0]].private_v4 } ] }}"
  14. when:
  15. - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
  16. - openshift_openstack_num_masters == 1
  17. - name: "Add public master cluster hostname records to the private A records (multi-master)"
  18. set_fact:
  19. private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[groups.masters[0]].openshift_master_cluster_public_hostname, 'ip': hostvars[groups.lb[0]].private_v4 } ] }}"
  20. when:
  21. - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
  22. - openshift_openstack_num_masters > 1
  23. - name: "Set the private DNS server to use the external value (if provided)"
  24. set_fact:
  25. nsupdate_server_private: "{{ openshift_openstack_external_nsupdate_keys['private']['server'] }}"
  26. nsupdate_key_secret_private: "{{ openshift_openstack_external_nsupdate_keys['private']['key_secret'] }}"
  27. nsupdate_key_algorithm_private: "{{ openshift_openstack_external_nsupdate_keys['private']['key_algorithm'] }}"
  28. nsupdate_private_key_name: "{{ openshift_openstack_external_nsupdate_keys['private']['key_name'] }}"
  29. when:
  30. - openshift_openstack_external_nsupdate_keys['private'] is defined
  31. - name: "Generate the private Add section for DNS"
  32. set_fact:
  33. private_named_records:
  34. - view: "private"
  35. zone: "{{ openshift_openstack_nsupdate_zone }}"
  36. server: "{{ nsupdate_server_private }}"
  37. key_name: "{{ nsupdate_private_key_name }}"
  38. key_secret: "{{ nsupdate_key_secret_private }}"
  39. key_algorithm: "{{ nsupdate_key_algorithm_private | lower }}"
  40. entries: "{{ private_records }}"
  41. when:
  42. - openshift_openstack_external_nsupdate_keys['private'] is defined
  43. - name: "Generate list of public A records"
  44. set_fact:
  45. public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[item]['ansible_hostname'] + openshift_openstack_public_hostname_suffix + '.' + openshift_openstack_full_dns_domain, 'ip': hostvars[item]['public_v4'] } ] }}"
  46. with_items: "{{ groups['cluster_hosts'] }}"
  47. when: hostvars[item]['public_v4'] is defined
  48. - name: "Add wildcard record to the public A records"
  49. set_fact:
  50. public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': '*.' + hostvars[groups.masters[0]].openshift_master_default_subdomain, 'ip': openshift_openstack_public_router_ip } ] }}"
  51. when: openshift_openstack_public_router_ip is defined
  52. - name: "Add the public API entry point record"
  53. set_fact:
  54. public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[groups.masters[0]].openshift_master_cluster_public_hostname, 'ip': openshift_openstack_public_api_ip } ] }}"
  55. when:
  56. - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
  57. - name: "Set the public DNS server details to use the external value (if provided)"
  58. set_fact:
  59. nsupdate_server_public: "{{ openshift_openstack_external_nsupdate_keys['public']['server'] }}"
  60. nsupdate_key_secret_public: "{{ openshift_openstack_external_nsupdate_keys['public']['key_secret'] }}"
  61. nsupdate_key_algorithm_public: "{{ openshift_openstack_external_nsupdate_keys['public']['key_algorithm'] }}"
  62. nsupdate_public_key_name: "{{ openshift_openstack_external_nsupdate_keys['public']['key_name'] }}"
  63. when:
  64. - openshift_openstack_external_nsupdate_keys['public'] is defined
  65. - name: "Generate the public Add section for DNS"
  66. set_fact:
  67. public_named_records:
  68. - view: "public"
  69. zone: "{{ openshift_openstack_nsupdate_zone }}"
  70. server: "{{ nsupdate_server_public }}"
  71. key_name: "{{ nsupdate_public_key_name }}"
  72. key_secret: "{{ nsupdate_key_secret_public }}"
  73. key_algorithm: "{{ nsupdate_key_algorithm_public | lower }}"
  74. entries: "{{ public_records }}"
  75. when:
  76. - openshift_openstack_external_nsupdate_keys['public'] is defined
  77. - name: "Generate the final openshift_openstack_dns_records"
  78. set_fact:
  79. openshift_openstack_dns_records: "{{ private_named_records|default([]) + public_named_records|default([]) }}"