evaluate_groups.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 to be set
  13. when: g_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. - name: Evaluate oo_etcd_to_config
  27. add_host:
  28. name: "{{ item }}"
  29. groups: oo_etcd_to_config
  30. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  31. ansible_sudo: "{{ g_sudo | default(omit) }}"
  32. with_items: "{{ g_etcd_hosts | default([]) }}"
  33. - name: Evaluate oo_masters_to_config
  34. add_host:
  35. name: "{{ item }}"
  36. groups: oo_masters_to_config
  37. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  38. ansible_sudo: "{{ g_sudo | default(omit) }}"
  39. with_items: "{{ g_master_hosts | default([]) }}"
  40. # Use g_new_node_hosts if it exists otherwise g_node_hosts
  41. - set_fact:
  42. g_node_hosts_to_config: "{{ g_new_node_hosts | default(g_node_hosts | default([])) }}"
  43. - name: Evaluate oo_nodes_to_config
  44. add_host:
  45. name: "{{ item }}"
  46. groups: oo_nodes_to_config
  47. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  48. ansible_sudo: "{{ g_sudo | default(omit) }}"
  49. with_items: "{{ g_node_hosts_to_config | default([]) }}"
  50. # Skip adding the master to oo_nodes_to_config when g_new_node_hosts is
  51. - name: Evaluate oo_nodes_to_config
  52. add_host:
  53. name: "{{ item }}"
  54. groups: oo_nodes_to_config
  55. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  56. ansible_sudo: "{{ g_sudo | default(omit) }}"
  57. with_items: "{{ g_master_hosts | default([]) }}"
  58. when: g_nodeonmaster | default(false) == true and g_new_node_hosts is not defined
  59. - name: Evaluate oo_first_etcd
  60. add_host:
  61. name: "{{ g_etcd_hosts[0] }}"
  62. groups: oo_first_etcd
  63. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  64. when: g_etcd_hosts|length > 0
  65. - name: Evaluate oo_first_master
  66. add_host:
  67. name: "{{ g_master_hosts[0] }}"
  68. groups: oo_first_master
  69. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  70. ansible_sudo: "{{ g_sudo | default(omit) }}"
  71. when: g_master_hosts|length > 0
  72. - name: Evaluate oo_lb_to_config
  73. add_host:
  74. name: "{{ item }}"
  75. groups: oo_lb_to_config
  76. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  77. ansible_sudo: "{{ g_sudo | default(omit) }}"
  78. with_items: "{{ g_lb_hosts | default([]) }}"
  79. - name: Evaluate oo_nfs_to_config
  80. add_host:
  81. name: "{{ item }}"
  82. groups: oo_nfs_to_config
  83. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  84. ansible_sudo: "{{ g_sudo | default(omit) }}"
  85. with_items: "{{ g_nfs_hosts | default([]) }}"