evaluate_groups.yml 7.0 KB

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