fetch_base_inputs.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. host_network_nic | length < 1 or
  33. host_network_dhcp_start_range | length < 1 or
  34. host_network_dhcp_end_range | length < 1 or
  35. provision_method | length < 1 or
  36. default_lease_time | length < 1 or
  37. provision_os | length < 1 or
  38. provision_state | length < 1 or
  39. mount_location | length < 1
  40. - name: Validate management network nic
  41. assert:
  42. that: mngmnt_network_nic | length > 1
  43. fail_msg: "{{ input_base_failure_msg }}"
  44. tags: validate
  45. when: device_config_support
  46. - name: Validate the value of device config support
  47. assert:
  48. that:
  49. - device_config_support | lower == "true" or device_config_support | lower == "false"
  50. success_msg: "{{ success_device_config }}"
  51. fail_msg: "{{ fail_device_config }}"
  52. tags: init
  53. - name: Set fact for device_ip_list_path
  54. set_fact:
  55. device_config_ip_file: false
  56. tags: init
  57. - name: Set the mapping file value for device network
  58. set_fact:
  59. device_config_ip_file: true
  60. when:
  61. - device_ip_list_path | length > 0
  62. - '"/" in device_ip_list_path'
  63. - idrac_support
  64. tags: init
  65. - name: Warning msg if idrac_support is false and device_ip_list is given
  66. assert:
  67. that:
  68. - '"/" in device_ip_list_path'
  69. success_msg: "{{ device_ip_list_not_supported }}"
  70. when: not idrac_support
  71. tags: validate
  72. failed_when: false
  73. - name: Set status for device_config_support
  74. set_fact:
  75. device_support_status: false
  76. tags: init
  77. - name: Validate contents of device_ip_list
  78. set_fact:
  79. device_support_status: true
  80. when: (device_config_support) or (idrac_support and device_config_ip_file)
  81. tags: init
  82. - name: Assert valid mngmnt_mapping_file_path
  83. stat:
  84. path: "{{ device_ip_list_path }}"
  85. when: device_config_ip_file
  86. register: result_device_ip_file
  87. tags: init
  88. - name : Valid device_ip_list
  89. fail:
  90. msg: "{{ invalid_mapping_file_path }} for configurations"
  91. when: device_config_ip_file and not result_device_ip_file.stat.exists
  92. tags: init
  93. - name: Validate default lease time
  94. assert:
  95. that:
  96. - default_lease_time|int
  97. - default_lease_time|int <= 31536000
  98. - default_lease_time|int >= 21600
  99. success_msg: "{{ success_msg_lease_time }}"
  100. fail_msg: "{{ fail_msg_lease_time }}"
  101. tags: [ validate, pxe, network-device, network-ib ]
  102. - name: Calculate max lease time
  103. set_fact:
  104. max_lease_time: "{{ default_lease_time|int + 10000 }}"
  105. tags: init
  106. - name: Set facts to validate snmp support
  107. set_fact:
  108. snmp_enabled: false
  109. mngmnt_mapping_file: false
  110. host_mapping_file: false
  111. tags: init
  112. - name: Verify snmp_trap_destination IP address
  113. set_fact:
  114. snmp_enabled: true
  115. when:
  116. - device_support_status
  117. - snmp_trap_destination | length > 1
  118. tags: init
  119. - name: Assert snmp trap destination address
  120. assert:
  121. that:
  122. - snmp_enabled
  123. - snmp_trap_destination | length > 7
  124. - snmp_trap_destination | ipv4
  125. success_msg: "{{ success_snmp_trap_dest }}"
  126. fail_msg: "{{ fail_snmp_trap_dest }}"
  127. when: snmp_enabled
  128. tags: [ validate, idrac, network-device, network-ib ]
  129. - name: Assert snmp community string
  130. assert:
  131. that:
  132. - snmp_enabled
  133. - snmp_community_name
  134. success_msg: "{{ success_snmp_comm_msg }}"
  135. fail_msg: "{{ fail_snmp_comm_msg }}"
  136. when: snmp_enabled
  137. tags: [ validate, idrac, network-device, network-ib ]
  138. - name: Check whether ansible config file exists
  139. stat:
  140. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  141. register: ansible_conf_exists
  142. tags: init
  143. - name: Create the directory if it does not exist
  144. file:
  145. path: "{{ ansible_conf_file_path }}"
  146. state: directory
  147. mode: "{{ file_perm }}"
  148. when: not ansible_conf_exists.stat.exists
  149. changed_when: false
  150. tags: init
  151. - name: Create ansible config file if it does not exist
  152. copy:
  153. dest: '{{ ansible_conf_file_path }}/ansible.cfg'
  154. mode: "{{ file_perm }}"
  155. content: |
  156. [defaults]
  157. log_path = /var/log/omnia.log
  158. when: not ansible_conf_exists.stat.exists
  159. tags: init
  160. - name: Validate infiniband base_vars are not empty
  161. assert:
  162. that:
  163. - ib_network_nic | length > 2
  164. - ib_network_dhcp_start_range | length > 6
  165. - ib_network_dhcp_end_range | length > 6
  166. success_msg: "{{ success_msg_ib }}"
  167. fail_msg: "{{ fail_msg_ib }}"
  168. register: ib_check
  169. when: ib_switch_support
  170. tags: [ validate, network-ib ]
  171. - name: Assert enable_security_support
  172. assert:
  173. that:
  174. - enable_security_support == true or enable_security_support == false
  175. success_msg: "{{ enable_security_support_success_msg }}"
  176. fail_msg: "{{ enable_security_support_fail_msg }}"
  177. tags: [ validate, init ]
  178. - name: Assert kubernetes pod network CIDR
  179. assert:
  180. that:
  181. - appliance_k8s_pod_net_cidr | ipv4
  182. - appliance_k8s_pod_net_cidr | length > 9
  183. - '"/" in appliance_k8s_pod_net_cidr '
  184. success_msg: "{{ success_msg_k8s_pod_network_cidr }}"
  185. fail_msg: "{{ fail_msg_k8s_pod_network_cidr }}"
  186. tags: [ validate, init ]
  187. - name: Assert organization in awx
  188. assert:
  189. that:
  190. - awx_organization | length >= min_username_length
  191. - awx_organization | length < max_length
  192. - '"-" not in awx_organization '
  193. - '"\\" not in awx_organization '
  194. - '"\"" not in awx_organization '
  195. - " \"'\" not in awx_organization "
  196. success_msg: "{{ success_awx_organization }}"
  197. fail_msg: "{{ fail_awx_organization }}"
  198. tags: [ validate, awx ]
  199. - name: Make mount directory for grafana if it doesnt exist
  200. file:
  201. path: "{{ mount_location }}"
  202. state: directory
  203. mode: "{{ mount_dir_perm }}"
  204. group: root
  205. owner: root
  206. tags: [ init, monitoring ]
  207. - name: Validate provision paramters
  208. import_tasks: validate_provision_vars.yml
  209. tags: [ validate, idrac, pxe ]
  210. - name: Validate device_config_support
  211. import_tasks: device_config_validations.yml
  212. - name: Validate device_config_support
  213. import_tasks: validate_device_ip_file.yml
  214. when: device_config_ip_file
  215. - name: Validate NIC parameters
  216. import_tasks: validate_nic_vars.yml