evaluate_groups.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. ---
  2. - name: Populate config host groups
  3. hosts: localhost
  4. connection: local
  5. become: no
  6. gather_facts: no
  7. tasks:
  8. - name: Load group name mapping variables
  9. include_vars: vars/cluster_hosts.yml
  10. - name: Evaluate groups - g_etcd_hosts or g_new_etcd_hosts required
  11. fail:
  12. msg: This playbook requires g_etcd_hosts or g_new_etcd_hosts to be set
  13. when: g_etcd_hosts is not defined and g_new_etcd_hosts is not defined
  14. - name: Evaluate groups - g_master_hosts or g_new_master_hosts required
  15. fail:
  16. msg: This playbook requires g_master_hosts or g_new_master_hosts to be set
  17. when: g_master_hosts is not defined and g_new_master_hosts is not defined
  18. - name: Evaluate groups - g_node_hosts or g_new_node_hosts required
  19. fail:
  20. msg: This playbook requires g_node_hosts or g_new_node_hosts to be set
  21. when: g_node_hosts is not defined and g_new_node_hosts is not defined
  22. - name: Evaluate groups - g_lb_hosts required
  23. fail:
  24. msg: This playbook requires g_lb_hosts to be set
  25. when: g_lb_hosts is not defined
  26. - name: Evaluate groups - g_nfs_hosts required
  27. fail:
  28. msg: This playbook requires g_nfs_hosts to be set
  29. when: g_nfs_hosts is not defined
  30. - name: Evaluate groups - g_nfs_hosts is single host
  31. fail:
  32. msg: The nfs group must be limited to one host
  33. when: g_nfs_hosts | default([]) | length > 1
  34. - name: Evaluate groups - g_glusterfs_hosts required
  35. fail:
  36. msg: This playbook requires g_glusterfs_hosts to be set
  37. when: g_glusterfs_hosts is not defined
  38. - name: Evaluate groups - Fail if no etcd hosts group is defined
  39. fail:
  40. msg: >
  41. Running etcd as an embedded service is no longer supported. If this is a
  42. new install please define an 'etcd' group with either one or three
  43. hosts. These hosts may be the same hosts as your masters. If this is an
  44. upgrade you may set openshift_master_unsupported_embedded_etcd=true
  45. until a migration playbook becomes available.
  46. when:
  47. - g_etcd_hosts | default([]) | length not in [3,1]
  48. - not openshift_master_unsupported_embedded_etcd | default(False)
  49. - not (openshift_node_bootstrap | default(False))
  50. - name: Evaluate oo_all_hosts
  51. add_host:
  52. name: "{{ item }}"
  53. groups: oo_all_hosts
  54. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  55. ansible_become: "{{ g_sudo | default(omit) }}"
  56. with_items: "{{ g_all_hosts | default([]) }}"
  57. changed_when: no
  58. - name: Evaluate oo_masters
  59. add_host:
  60. name: "{{ item }}"
  61. groups: oo_masters
  62. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  63. ansible_become: "{{ g_sudo | default(omit) }}"
  64. with_items: "{{ g_master_hosts | union(g_new_master_hosts) | default([]) }}"
  65. changed_when: no
  66. - name: Evaluate oo_first_master
  67. add_host:
  68. name: "{{ g_master_hosts[0] }}"
  69. groups: oo_first_master
  70. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  71. ansible_become: "{{ g_sudo | default(omit) }}"
  72. when: g_master_hosts|length > 0
  73. changed_when: no
  74. - name: Evaluate oo_new_etcd_to_config
  75. add_host:
  76. name: "{{ item }}"
  77. groups: oo_new_etcd_to_config
  78. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  79. ansible_become: "{{ g_sudo | default(omit) }}"
  80. with_items: "{{ g_new_etcd_hosts | default([]) }}"
  81. changed_when: no
  82. - name: Evaluate oo_masters_to_config
  83. add_host:
  84. name: "{{ item }}"
  85. groups: oo_masters_to_config
  86. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  87. ansible_become: "{{ g_sudo | default(omit) }}"
  88. with_items: "{{ g_new_master_hosts | default(g_master_hosts | default([], true), true) }}"
  89. changed_when: no
  90. - name: Evaluate oo_etcd_to_config
  91. add_host:
  92. name: "{{ item }}"
  93. groups: oo_etcd_to_config
  94. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  95. ansible_become: "{{ g_sudo | default(omit) }}"
  96. with_items: "{{ g_etcd_hosts | default([]) }}"
  97. changed_when: no
  98. - name: Evaluate oo_first_etcd
  99. add_host:
  100. name: "{{ g_etcd_hosts[0] }}"
  101. groups: oo_first_etcd
  102. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  103. ansible_become: "{{ g_sudo | default(omit) }}"
  104. when: g_etcd_hosts|length > 0
  105. changed_when: no
  106. # We use two groups one for hosts we're upgrading which doesn't include embedded etcd
  107. # The other for backing up which includes the embedded etcd host, there's no need to
  108. # upgrade embedded etcd that just happens when the master is updated.
  109. - name: Evaluate oo_etcd_hosts_to_upgrade
  110. add_host:
  111. name: "{{ item }}"
  112. groups: oo_etcd_hosts_to_upgrade
  113. with_items: "{{ groups.oo_etcd_to_config if groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 else [] }}"
  114. changed_when: False
  115. - name: Evaluate oo_etcd_hosts_to_backup
  116. add_host:
  117. name: "{{ item }}"
  118. groups: oo_etcd_hosts_to_backup
  119. with_items: "{{ groups.oo_etcd_to_config if groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 else (groups.oo_first_master | default([])) }}"
  120. changed_when: False
  121. - name: Evaluate oo_nodes_to_config
  122. add_host:
  123. name: "{{ item }}"
  124. groups: oo_nodes_to_config
  125. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  126. ansible_become: "{{ g_sudo | default(omit) }}"
  127. with_items: "{{ g_new_node_hosts | default(g_node_hosts | default([], true), true) }}"
  128. changed_when: no
  129. # Skip adding the master to oo_nodes_to_config when g_new_node_hosts is
  130. - name: Add master to oo_nodes_to_config
  131. add_host:
  132. name: "{{ item }}"
  133. groups: oo_nodes_to_config
  134. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  135. ansible_become: "{{ g_sudo | default(omit) }}"
  136. with_items: "{{ g_master_hosts | default([]) }}"
  137. when: g_nodeonmaster | default(false) | bool and not g_new_node_hosts | default(false) | bool
  138. changed_when: no
  139. - name: Evaluate oo_lb_to_config
  140. add_host:
  141. name: "{{ item }}"
  142. groups: oo_lb_to_config
  143. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  144. ansible_become: "{{ g_sudo | default(omit) }}"
  145. with_items: "{{ g_lb_hosts | default([]) }}"
  146. changed_when: no
  147. - name: Evaluate oo_nfs_to_config
  148. add_host:
  149. name: "{{ item }}"
  150. groups: oo_nfs_to_config
  151. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  152. ansible_become: "{{ g_sudo | default(omit) }}"
  153. with_items: "{{ g_nfs_hosts | default([]) }}"
  154. changed_when: no
  155. - name: Evaluate oo_glusterfs_to_config
  156. add_host:
  157. name: "{{ item }}"
  158. groups: oo_glusterfs_to_config
  159. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  160. ansible_become: "{{ g_sudo | default(omit) }}"
  161. with_items: "{{ g_glusterfs_hosts | union(g_glusterfs_registry_hosts | default([])) }}"
  162. changed_when: no
  163. - name: Evaluate oo_etcd_to_migrate
  164. add_host:
  165. name: "{{ item }}"
  166. groups: oo_etcd_to_migrate
  167. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  168. ansible_become: "{{ g_sudo | default(omit) }}"
  169. with_items: "{{ groups.oo_etcd_to_config if groups.oo_etcd_to_config | default([]) | length != 0 else (groups.oo_first_master |default([]))}}"
  170. changed_when: no