generate-dns.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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['OSEv3'] }}"
  6. when:
  7. - hostvars[item]['private_v4'] is defined
  8. - hostvars[item]['private_v4'] is not none
  9. - hostvars[item]['private_v4'] | string
  10. - name: "Add wildcard records to the private A records for infrahosts"
  11. set_fact:
  12. private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': '*.' + hostvars[groups.masters[0]].openshift_master_default_subdomain, 'ip': hostvars[item]['private_v4'] } ] }}"
  13. with_items: "{{ groups['openstack_infra_nodes'] }}"
  14. when:
  15. - groups.masters
  16. - hostvars[groups.masters[0]].openshift_master_default_subdomain is defined
  17. - openshift_openstack_public_router_ip is defined
  18. - openshift_openstack_public_router_ip is not none
  19. - openshift_openstack_public_router_ip | string
  20. - debug: var=openshift_openstack_private_api_ip
  21. - name: "Add public master cluster hostname records to the private A records"
  22. set_fact:
  23. private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[groups.masters[0]].openshift_master_cluster_public_hostname, 'ip': openshift_openstack_private_api_ip } ] }}"
  24. when:
  25. - groups.masters
  26. - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
  27. - openshift_openstack_private_api_ip is defined
  28. - openshift_openstack_private_api_ip is not none
  29. - openshift_openstack_private_api_ip | string
  30. - name: "Set the private DNS server to use the external value (if provided)"
  31. set_fact:
  32. nsupdate_server_private: "{{ openshift_openstack_external_nsupdate_keys['private']['server'] }}"
  33. nsupdate_key_secret_private: "{{ openshift_openstack_external_nsupdate_keys['private']['key_secret'] }}"
  34. nsupdate_key_algorithm_private: "{{ openshift_openstack_external_nsupdate_keys['private']['key_algorithm'] }}"
  35. nsupdate_private_key_name: "{{ openshift_openstack_external_nsupdate_keys['private']['key_name'] }}"
  36. when:
  37. - openshift_openstack_external_nsupdate_keys['private'] is defined
  38. - name: "Generate the private Add section for DNS"
  39. set_fact:
  40. private_named_records:
  41. - view: "private"
  42. zone: "{{ openshift_openstack_nsupdate_zone }}"
  43. server: "{{ nsupdate_server_private }}"
  44. key_name: "{{ nsupdate_private_key_name }}"
  45. key_secret: "{{ nsupdate_key_secret_private }}"
  46. key_algorithm: "{{ nsupdate_key_algorithm_private | lower }}"
  47. entries: "{{ private_records }}"
  48. when:
  49. - openshift_openstack_external_nsupdate_keys['private'] is defined
  50. - private_records is defined
  51. - name: "Generate list of public A records"
  52. set_fact:
  53. 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'] } ] }}"
  54. with_items: "{{ groups['OSEv3'] }}"
  55. when:
  56. - hostvars[item]['public_v4'] is defined
  57. - hostvars[item]['public_v4'] | string
  58. - name: "Add wildcard record to the public A records"
  59. set_fact:
  60. public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': '*.' + hostvars[groups.masters[0]].openshift_master_default_subdomain, 'ip': openshift_openstack_public_router_ip } ] }}"
  61. when:
  62. - groups.masters
  63. - hostvars[groups.masters[0]].openshift_master_default_subdomain is defined
  64. - openshift_openstack_public_router_ip is defined
  65. - openshift_openstack_public_router_ip is not none
  66. - openshift_openstack_public_router_ip | string
  67. - name: "Add the public API entry point record"
  68. set_fact:
  69. public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[groups.masters[0]].openshift_master_cluster_public_hostname, 'ip': openshift_openstack_public_api_ip } ] }}"
  70. when:
  71. - groups.masters
  72. - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
  73. - openshift_openstack_public_api_ip is defined
  74. - openshift_openstack_public_api_ip is not none
  75. - openshift_openstack_public_api_ip | string
  76. - name: "Set the public DNS server details to use the external value (if provided)"
  77. set_fact:
  78. nsupdate_server_public: "{{ openshift_openstack_external_nsupdate_keys['public']['server'] }}"
  79. nsupdate_key_secret_public: "{{ openshift_openstack_external_nsupdate_keys['public']['key_secret'] }}"
  80. nsupdate_key_algorithm_public: "{{ openshift_openstack_external_nsupdate_keys['public']['key_algorithm'] }}"
  81. nsupdate_public_key_name: "{{ openshift_openstack_external_nsupdate_keys['public']['key_name'] }}"
  82. when:
  83. - openshift_openstack_external_nsupdate_keys['public'] is defined
  84. - name: "Generate the public Add section for DNS"
  85. set_fact:
  86. public_named_records:
  87. - view: "public"
  88. zone: "{{ openshift_openstack_nsupdate_zone }}"
  89. server: "{{ nsupdate_server_public }}"
  90. key_name: "{{ nsupdate_public_key_name }}"
  91. key_secret: "{{ nsupdate_key_secret_public }}"
  92. key_algorithm: "{{ nsupdate_key_algorithm_public | lower }}"
  93. entries: "{{ public_records }}"
  94. when:
  95. - openshift_openstack_external_nsupdate_keys['public'] is defined
  96. - public_records is defined
  97. - name: "Generate the final openshift_openstack_dns_records"
  98. set_fact:
  99. openshift_openstack_dns_records: "{{ private_named_records|default([]) + public_named_records|default([]) }}"