fetch_base_inputs.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Include base variable file base_vars.yml
  16. include_vars: "{{ base_vars_filename }}"
  17. no_log: true
  18. tags: init
  19. - name: Validate input parameters of base_vars are not empty
  20. fail:
  21. msg: "{{ input_base_failure_msg }}"
  22. register: input_base_check
  23. tags: validate
  24. when:
  25. - ansible_conf_file_path | length < 1 or
  26. public_nic | length < 1 or
  27. appliance_k8s_pod_net_cidr | length < 1 or
  28. awx_organization | length < 1 or
  29. timezone | length < 1 or
  30. language | length < 1 or
  31. iso_file_path | length < 1 or
  32. mngmnt_network_nic | length < 1 or
  33. mngmnt_network_dhcp_start_range | length < 1 or
  34. mngmnt_network_dhcp_end_range | length < 1 or
  35. host_network_nic | length < 1 or
  36. host_network_dhcp_start_range | length < 1 or
  37. host_network_dhcp_end_range | length < 1 or
  38. provision_method | length < 1 or
  39. default_lease_time | length < 1 or
  40. provision_os | length < 1 or
  41. provision_state | length < 1 or
  42. mount_location | length < 1
  43. - name: Validate default lease time
  44. assert:
  45. that:
  46. - default_lease_time|int
  47. - default_lease_time|int <= 31536000
  48. - default_lease_time|int >= 21600
  49. success_msg: "{{ success_msg_lease_time }}"
  50. fail_msg: "{{ fail_msg_lease_time }}"
  51. tags: [ validate, pxe, network-device, network-ib ]
  52. - name: Calculate max lease time
  53. set_fact:
  54. max_lease_time: "{{ default_lease_time|int + 10000 }}"
  55. tags: init
  56. - name: Validate infiniband base_vars are not empty
  57. assert:
  58. that:
  59. - ib_network_nic | length > 2
  60. - ib_network_dhcp_start_range | length > 6
  61. - ib_network_dhcp_end_range | length > 6
  62. success_msg: "{{ success_msg_ib }}"
  63. fail_msg: "{{ fail_msg_ib }}"
  64. register: ib_check
  65. when: ib_switch_support
  66. tags: [ validate, network-ib ]
  67. - name: Set facts to validate snmp support
  68. set_fact:
  69. snmp_enabled: false
  70. mngmnt_mapping_file: false
  71. host_mapping_file: false
  72. tags: init
  73. - name: Verify snmp_trap_destination IP address
  74. set_fact:
  75. snmp_enabled: true
  76. when: snmp_trap_destination | length > 1
  77. tags: init
  78. - name: Assert snmp trap destination address
  79. assert:
  80. that:
  81. - snmp_enabled
  82. - snmp_trap_destination | length > 7
  83. - snmp_trap_destination | ipv4
  84. success_msg: "{{ success_snmp_trap_dest }}"
  85. fail_msg: "{{ fail_snmp_trap_dest }}"
  86. when: snmp_enabled
  87. tags: [ validate, idrac, network-device, network-ib ]
  88. - name: Assert snmp community string
  89. assert:
  90. that:
  91. - snmp_enabled
  92. - snmp_community_name
  93. success_msg: "{{ success_snmp_comm_msg }}"
  94. fail_msg: "{{ fail_snmp_comm_msg }}"
  95. when: snmp_enabled
  96. tags: [ validate, idrac, network-device, network-ib ]
  97. - name: Check whether ansible config file exists
  98. stat:
  99. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  100. register: ansible_conf_exists
  101. tags: init
  102. - name: Create the directory if it does not exist
  103. file:
  104. path: "{{ ansible_conf_file_path }}"
  105. state: directory
  106. mode: "{{ file_perm }}"
  107. when: not ansible_conf_exists.stat.exists
  108. changed_when: false
  109. tags: init
  110. - name: Create ansible config file if it does not exist
  111. copy:
  112. dest: '{{ ansible_conf_file_path }}/ansible.cfg'
  113. mode: "{{ file_perm }}"
  114. content: |
  115. [defaults]
  116. log_path = /var/log/omnia.log
  117. when: not ansible_conf_exists.stat.exists
  118. tags: init
  119. - name: Assert ethernet_switch_support
  120. assert:
  121. that:
  122. - ethernet_switch_support == true or ethernet_switch_support == false
  123. success_msg: "{{ ethernet_switch_support_success_msg }}"
  124. fail_msg: "{{ ethernet_switch_support_fail_msg }}"
  125. tags: [ validate, init ]
  126. - name: Assert ib_switch_support
  127. assert:
  128. that:
  129. - ib_switch_support == true or ib_switch_support == false
  130. success_msg: "{{ ib_switch_support_success_msg }}"
  131. fail_msg: "{{ ib_switch_support_fail_msg }}"
  132. tags: [ validate, init ]
  133. - name: Assert powervault_support
  134. assert:
  135. that:
  136. - powervault_support == true or powervault_support == false
  137. success_msg: "{{ powervault_support_success_msg }}"
  138. fail_msg: "{{ powervault_support_fail_msg }}"
  139. tags: [ validate, init ]
  140. - name: Assert enable_security_support
  141. assert:
  142. that:
  143. - enable_security_support == true or enable_security_support == false
  144. success_msg: "{{ enable_security_support_success_msg }}"
  145. fail_msg: "{{ enable_security_support_fail_msg }}"
  146. tags: [ validate, init ]
  147. - name: Assert kubernetes pod network CIDR
  148. assert:
  149. that:
  150. - appliance_k8s_pod_net_cidr | ipv4
  151. - appliance_k8s_pod_net_cidr | length > 9
  152. - '"/" in appliance_k8s_pod_net_cidr '
  153. success_msg: "{{ success_msg_k8s_pod_network_cidr }}"
  154. fail_msg: "{{ fail_msg_k8s_pod_network_cidr }}"
  155. tags: [ validate, init ]
  156. - name: Assert organization in awx
  157. assert:
  158. that:
  159. - awx_organization | length >= min_username_length
  160. - awx_organization | length < max_length
  161. - '"-" not in awx_organization '
  162. - '"\\" not in awx_organization '
  163. - '"\"" not in awx_organization '
  164. - " \"'\" not in awx_organization "
  165. success_msg: "{{ success_awx_organization }}"
  166. fail_msg: "{{ fail_awx_organization }}"
  167. tags: [ validate, awx ]
  168. - name: Make mount directory for grafana if it doesnt exist
  169. file:
  170. path: "{{ mount_location }}"
  171. state: directory
  172. mode: "{{ mount_dir_perm }}"
  173. group: root
  174. owner: root
  175. tags: [ init, monitoring ]
  176. - name: Validate provision paramters
  177. import_tasks: validate_provision_vars.yml
  178. tags: [ validate, idrac, pxe ]
  179. - name: Validate NIC parameters
  180. import_tasks: validate_nic_vars.yml