evaluate_groups.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ---
  2. - name: Populate config host groups
  3. hosts: localhost
  4. connection: local
  5. become: no
  6. gather_facts: no
  7. tasks:
  8. - fail:
  9. msg: This playbook requires g_etcd_hosts to be set
  10. when: g_etcd_hosts is not defined
  11. - fail:
  12. msg: This playbook requires g_master_hosts or g_new_master_hosts to be set
  13. when: g_master_hosts is not defined and g_new_master_hosts is not defined
  14. - fail:
  15. msg: This playbook requires g_node_hosts or g_new_node_hosts to be set
  16. when: g_node_hosts is not defined and g_new_node_hosts is not defined
  17. - fail:
  18. msg: This playbook requires g_lb_hosts to be set
  19. when: g_lb_hosts is not defined
  20. - fail:
  21. msg: This playbook requires g_nfs_hosts to be set
  22. when: g_nfs_hosts is not defined
  23. - fail:
  24. msg: The nfs group must be limited to one host
  25. when: (groups[g_nfs_hosts] | default([])) | length > 1
  26. - fail:
  27. msg: This playbook requires g_glusterfs_hosts to be set
  28. when: g_glusterfs_hosts is not defined
  29. - name: Evaluate oo_all_hosts
  30. add_host:
  31. name: "{{ item }}"
  32. groups: oo_all_hosts
  33. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  34. ansible_become: "{{ g_sudo | default(omit) }}"
  35. with_items: "{{ g_all_hosts | default([]) }}"
  36. changed_when: no
  37. - name: Evaluate oo_masters
  38. add_host:
  39. name: "{{ item }}"
  40. groups: oo_masters
  41. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  42. ansible_become: "{{ g_sudo | default(omit) }}"
  43. with_items: "{{ g_master_hosts | union(g_new_master_hosts) | default([]) }}"
  44. changed_when: no
  45. - name: Evaluate oo_etcd_to_config
  46. add_host:
  47. name: "{{ item }}"
  48. groups: oo_etcd_to_config
  49. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  50. ansible_become: "{{ g_sudo | default(omit) }}"
  51. with_items: "{{ g_etcd_hosts | default([]) }}"
  52. changed_when: no
  53. - name: Evaluate oo_masters_to_config
  54. add_host:
  55. name: "{{ item }}"
  56. groups: oo_masters_to_config
  57. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  58. ansible_become: "{{ g_sudo | default(omit) }}"
  59. with_items: "{{ g_new_master_hosts | default(g_master_hosts | default([], true), true) }}"
  60. changed_when: no
  61. - name: Evaluate oo_nodes_to_config
  62. add_host:
  63. name: "{{ item }}"
  64. groups: oo_nodes_to_config
  65. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  66. ansible_become: "{{ g_sudo | default(omit) }}"
  67. with_items: "{{ g_new_node_hosts | default(g_node_hosts | default([], true), true) }}"
  68. changed_when: no
  69. # Skip adding the master to oo_nodes_to_config when g_new_node_hosts is
  70. - name: Add master to oo_nodes_to_config
  71. add_host:
  72. name: "{{ item }}"
  73. groups: oo_nodes_to_config
  74. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  75. ansible_become: "{{ g_sudo | default(omit) }}"
  76. with_items: "{{ g_master_hosts | default([]) }}"
  77. when: g_nodeonmaster | default(false) | bool and not g_new_node_hosts | default(false) | bool
  78. changed_when: no
  79. - name: Evaluate oo_first_etcd
  80. add_host:
  81. name: "{{ g_etcd_hosts[0] }}"
  82. groups: oo_first_etcd
  83. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  84. when: g_etcd_hosts|length > 0
  85. changed_when: no
  86. - name: Evaluate oo_first_master
  87. add_host:
  88. name: "{{ g_master_hosts[0] }}"
  89. groups: oo_first_master
  90. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  91. ansible_become: "{{ g_sudo | default(omit) }}"
  92. when: g_master_hosts|length > 0
  93. changed_when: no
  94. - name: Evaluate oo_lb_to_config
  95. add_host:
  96. name: "{{ item }}"
  97. groups: oo_lb_to_config
  98. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  99. ansible_become: "{{ g_sudo | default(omit) }}"
  100. with_items: "{{ g_lb_hosts | default([]) }}"
  101. changed_when: no
  102. - name: Evaluate oo_nfs_to_config
  103. add_host:
  104. name: "{{ item }}"
  105. groups: oo_nfs_to_config
  106. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  107. ansible_become: "{{ g_sudo | default(omit) }}"
  108. with_items: "{{ g_nfs_hosts | default([]) }}"
  109. changed_when: no
  110. - name: Evaluate oo_glusterfs_to_config
  111. add_host:
  112. name: "{{ item }}"
  113. groups: oo_glusterfs_to_config
  114. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  115. ansible_become: "{{ g_sudo | default(omit) }}"
  116. with_items: "{{ g_glusterfs_hosts | default([]) }}"
  117. changed_when: no