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