fetch_base_inputs.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. # Copyright 2021 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. - name: Validate input parameters of base_vars are not empty
  19. fail:
  20. msg: "{{ input_base_failure_msg }}"
  21. register: input_base_check
  22. when:
  23. - ansible_conf_file_path | length < 1 or
  24. public_nic | length < 1 or
  25. appliance_k8s_pod_net_cidr | length < 1 or
  26. awx_organization | length < 1 or
  27. timezone | length < 1 or
  28. language | length < 1 or
  29. iso_file_path | length < 1 or
  30. mngmnt_network_nic | length < 1 or
  31. mngmnt_network_dhcp_start_range | length < 1 or
  32. mngmnt_network_dhcp_end_range | length < 1 or
  33. host_network_nic | length < 1 or
  34. host_network_dhcp_start_range | length < 1 or
  35. host_network_dhcp_end_range | length < 1 or
  36. provision_method | length < 1 or
  37. default_lease_time | length < 1 or
  38. provision_os | length < 1 or
  39. provision_state | length < 1
  40. - name: Validate default lease time
  41. assert:
  42. that:
  43. - default_lease_time|int
  44. - default_lease_time|int <= 31536000
  45. - default_lease_time|int >= 21600
  46. success_msg: "{{ success_msg_lease_time }}"
  47. fail_msg: "{{ fail_msg_lease_time }}"
  48. - name: Calculate max lease time
  49. set_fact:
  50. max_lease_time: "{{ default_lease_time|int + 10000 }}"
  51. - name: Validate infiniband base_vars are not empty
  52. assert:
  53. that:
  54. - ib_network_nic | length > 2
  55. - ib_network_dhcp_start_range | length > 6
  56. - ib_network_dhcp_end_range | length > 6
  57. success_msg: "{{ success_msg_ib }}"
  58. fail_msg: "{{ fail_msg_ib }}"
  59. register: ib_check
  60. when: ib_switch_support
  61. - name: Set facts to validate snmp support
  62. set_fact:
  63. snmp_enabled: false
  64. mngmnt_mapping_file: false
  65. host_mapping_file: false
  66. - name: Verify snmp_trap_destination IP address
  67. set_fact:
  68. snmp_enabled: true
  69. when: snmp_trap_destination | length > 1
  70. - name: Assert snmp trap destination address
  71. assert:
  72. that:
  73. - snmp_enabled
  74. - snmp_trap_destination | length > 7
  75. - snmp_trap_destination | ipv4
  76. success_msg: "{{ success_snmp_trap_dest }}"
  77. fail_msg: "{{ fail_snmp_trap_dest }}"
  78. when: snmp_enabled
  79. - name: Assert snmp community string
  80. assert:
  81. that:
  82. - snmp_enabled
  83. - snmp_community_name
  84. success_msg: "{{ success_snmp_comm_msg }}"
  85. fail_msg: "{{ fail_snmp_comm_msg }}"
  86. when: snmp_enabled
  87. - name: Check whether ansible config file exists
  88. stat:
  89. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  90. register: ansible_conf_exists
  91. - name: Create the directory if it does not exist
  92. file:
  93. path: "{{ ansible_conf_file_path }}"
  94. state: directory
  95. mode: "{{ file_perm }}"
  96. when: not ansible_conf_exists.stat.exists
  97. changed_when: false
  98. - name: Create ansible config file if it does not exist
  99. copy:
  100. dest: '{{ ansible_conf_file_path }}/ansible.cfg'
  101. mode: "{{ file_perm }}"
  102. content: |
  103. [defaults]
  104. log_path = /var/log/omnia.log
  105. when: not ansible_conf_exists.stat.exists
  106. - name: Assert ethernet_switch_support
  107. assert:
  108. that:
  109. - ethernet_switch_support == true or ethernet_switch_support == false
  110. success_msg: "{{ ethernet_switch_support_success_msg }}"
  111. fail_msg: "{{ ethernet_switch_support_fail_msg }}"
  112. - name: Assert ib_switch_support
  113. assert:
  114. that:
  115. - ib_switch_support == true or ib_switch_support == false
  116. success_msg: "{{ ib_switch_support_success_msg }}"
  117. fail_msg: "{{ ib_switch_support_fail_msg }}"
  118. - name: Assert powervault_support
  119. assert:
  120. that:
  121. - powervault_support == true or powervault_support == false
  122. success_msg: "{{ powervault_support_success_msg }}"
  123. fail_msg: "{{ powervault_support_fail_msg }}"
  124. - name: Fetch the network interfaces in UP state in the system
  125. shell: set -o pipefail && ip a | awk '/state UP/{print $2}'
  126. register: nic_addr_up
  127. changed_when: false
  128. - name: Assert public nic
  129. assert:
  130. that:
  131. - public_nic in nic_addr_up.stdout
  132. success_msg: "{{ success_msg_public_nic }}"
  133. fail_msg: "{{ fail_msg_public_nic }}"
  134. - name: Fetch the system public IP
  135. set_fact:
  136. public_ip: "{{ lookup('vars','ansible_'+public_nic).ipv4.address }}"
  137. - name: Assert kubernetes pod network CIDR
  138. assert:
  139. that:
  140. - appliance_k8s_pod_net_cidr | ipv4
  141. - appliance_k8s_pod_net_cidr | length > 9
  142. - '"/" in appliance_k8s_pod_net_cidr '
  143. success_msg: "{{ success_msg_k8s_pod_network_cidr }}"
  144. fail_msg: "{{ fail_msg_k8s_pod_network_cidr }}"
  145. - name: Assert Organization in awx
  146. assert:
  147. that:
  148. - awx_organization | length >= min_username_length
  149. - awx_organization | length < max_length
  150. - '"-" not in awx_organization '
  151. - '"\\" not in awx_organization '
  152. - '"\"" not in awx_organization '
  153. - " \"'\" not in awx_organization "
  154. success_msg: "{{ success_awx_organization }}"
  155. fail_msg: "{{ fail_awx_organization }}"
  156. - name: Convert timezone.txt to linux format
  157. command: dos2unix {{ role_path }}/files/timezone.txt
  158. failed_when: false
  159. changed_when: false
  160. - name: Check timezone file
  161. command: grep -Fx "{{ timezone }}" {{ role_path }}/files/timezone.txt
  162. failed_when: false
  163. register: timezone_out
  164. changed_when: false
  165. - name: Assert timezone
  166. assert:
  167. that: timezone in timezone_out.stdout
  168. success_msg: "{{ success_timezone_msg }}"
  169. fail_msg: "{{ fail_timezone_msg }}"
  170. register: timezone_check
  171. - name: Assert language for provisioning nodes
  172. fail:
  173. msg: "{{ fail_language }}"
  174. when: '"en-US" not in language'
  175. - name: Assert provisioning method
  176. assert:
  177. that:
  178. - provision_method == "PXE" or provision_method == "idrac"
  179. success_msg: "{{ success_provision_method }}"
  180. fail_msg: "{{ fail_provision_method }}"
  181. - name: Assert provision_state
  182. assert:
  183. that:
  184. - provision_state == "stateful"
  185. fail_msg: "{{ provision_state_fail_msg }}"
  186. success_msg: "{{ provision_state_success_msg }}"
  187. - name: Assert operating system
  188. assert:
  189. that:
  190. - provision_os == os_supported_centos or
  191. provision_os == os_supported_rocky
  192. fail_msg: "{{ provision_os_fail_msg }}"
  193. success_msg: "{{ provision_os_success_msg }}"
  194. - name: Verify the iso_file_path
  195. stat:
  196. path: "{{ iso_file_path }}"
  197. register: result_path_iso_file
  198. - name : Assert iso_file_path location
  199. fail:
  200. msg: "{{ missing_iso_file_path }}"
  201. when: not result_path_iso_file.stat.exists
  202. - name: Validate iso_file_path name
  203. assert:
  204. that:
  205. - result_path_iso_file.stat.exists
  206. - '".iso" in iso_file_path'
  207. - provision_os in iso_file_path | lower
  208. fail_msg: "{{ invalid_iso_file_path }}"
  209. success_msg: "{{ valid_iso_file_path }}"
  210. #### management_net_dhcp_start_end_range
  211. - name: Assert management network nic
  212. assert:
  213. that:
  214. - mngmnt_network_nic in nic_addr_up.stdout
  215. success_msg: "{{ success_msg_mngmnt_network_nic }}"
  216. fail_msg: "{{ fail_msg_mngmnt_network_nic }}"
  217. - name: Fetch the management network ip, netmask and subnet
  218. set_fact:
  219. mngmnt_network_ip: "{{ lookup('vars','ansible_'+mngmnt_network_nic).ipv4.address }}"
  220. mngmnt_network_netmask: "{{ lookup('vars','ansible_'+mngmnt_network_nic).ipv4.netmask }}"
  221. mngmnt_network_subnet: "{{ lookup('vars','ansible_'+mngmnt_network_nic).ipv4.network }}"
  222. - name: Check the subnet of management network dhcp start range
  223. shell: |
  224. IFS=. read -r i1 i2 i3 i4 <<< "{{ mngmnt_network_dhcp_start_range }}"
  225. IFS=. read -r m1 m2 m3 m4 <<< "{{ mngmnt_network_netmask }}"
  226. printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
  227. args:
  228. warn: no
  229. register: dhcp_start_mgmnt_result
  230. changed_when: false
  231. - name: Set the start dhcp subnet for management network
  232. set_fact:
  233. dhcp_start_mgmnt: "{{ dhcp_start_mgmnt_result.stdout }}"
  234. - name: Check the subnet of dhcp end range for management network
  235. shell: |
  236. IFS=. read -r i1 i2 i3 i4 <<< "{{ mngmnt_network_dhcp_end_range }}"
  237. IFS=. read -r m1 m2 m3 m4 <<< "{{ mngmnt_network_netmask }}"
  238. printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
  239. register: dhcp_end_mgmnt_result
  240. changed_when: false
  241. - name: Set the end dhcp subnet for management network
  242. set_fact:
  243. dhcp_end_mgmnt: "{{ dhcp_end_mgmnt_result.stdout }}"
  244. - name: Assert management_net_dhcp_start_range
  245. assert:
  246. that:
  247. - mngmnt_network_dhcp_start_range
  248. - mngmnt_network_dhcp_start_range | ipv4
  249. - mngmnt_network_dhcp_start_range != mngmnt_network_ip
  250. - mngmnt_network_dhcp_start_range != mngmnt_network_dhcp_end_range
  251. - dhcp_start_mgmnt == mngmnt_network_subnet
  252. - dhcp_start_mgmnt == dhcp_end_mgmnt
  253. success_msg: "{{ success_dhcp_range }} for management network"
  254. fail_msg: "{{ fail_dhcp_range }} for management network"
  255. - name: Assert management_net_dhcp_end_range
  256. assert:
  257. that:
  258. - mngmnt_network_dhcp_end_range
  259. - mngmnt_network_dhcp_end_range | ipv4
  260. - mngmnt_network_dhcp_end_range != mngmnt_network_ip
  261. - mngmnt_network_dhcp_start_range != mngmnt_network_dhcp_end_range
  262. - dhcp_end_mgmnt == mngmnt_network_subnet
  263. - dhcp_start_mgmnt == dhcp_end_mgmnt
  264. success_msg: "{{ success_dhcp_range }} for management network"
  265. fail_msg: "{{ fail_dhcp_range }} for management network"
  266. - name: Set the mapping file value for management network
  267. set_fact:
  268. mngmnt_mapping_file: true
  269. when: mngmnt_mapping_file_path | length > 0
  270. - name: Assert valid mngmnt_mapping_file_path
  271. stat:
  272. path: "{{ mngmnt_mapping_file_path }}"
  273. when: mngmnt_mapping_file
  274. register: result_mngmnt_mapping_file
  275. - name : Valid mngmnt_mapping_file_path
  276. fail:
  277. msg: "{{ invalid_mapping_file_path }} for management network"
  278. when: mngmnt_mapping_file and not result_mngmnt_mapping_file.stat.exists
  279. #########
  280. ###Host network####
  281. - name: Fetch the host network ip, netmask and subnet
  282. set_fact:
  283. hpc_ip: "{{ lookup('vars','ansible_'+host_network_nic).ipv4.address }}"
  284. netmask: "{{ lookup('vars','ansible_'+host_network_nic).ipv4.netmask }}"
  285. subnet: "{{ lookup('vars','ansible_'+host_network_nic).ipv4.network }}"
  286. - name: Check the subnet of host network dhcp start range
  287. shell: |
  288. IFS=. read -r i1 i2 i3 i4 <<< "{{ host_network_dhcp_start_range }}"
  289. IFS=. read -r m1 m2 m3 m4 <<< "{{ netmask }}"
  290. printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
  291. args:
  292. warn: no
  293. register: dhcp_start_host_result
  294. changed_when: false
  295. - name: Set the start dhcp subnet for host network
  296. set_fact:
  297. dhcp_start_host: "{{ dhcp_start_host_result.stdout }}"
  298. - name: Check the subnet of dhcp end range for host network
  299. shell: |
  300. IFS=. read -r i1 i2 i3 i4 <<< "{{ host_network_dhcp_end_range }}"
  301. IFS=. read -r m1 m2 m3 m4 <<< "{{ netmask }}"
  302. printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
  303. register: dhcp_end_host_result
  304. changed_when: false
  305. - name: Set the end dhcp subnet for host network
  306. set_fact:
  307. dhcp_end_host: "{{ dhcp_end_host_result.stdout }}"
  308. - name: Assert host_network_dhcp_start_range
  309. assert:
  310. that:
  311. - host_network_dhcp_start_range
  312. - host_network_dhcp_start_range | ipv4
  313. - host_network_dhcp_start_range != hpc_ip
  314. - host_network_dhcp_start_range != host_network_dhcp_end_range
  315. - dhcp_start_host == subnet
  316. - dhcp_start_host == dhcp_end_host
  317. success_msg: "{{ success_dhcp_range }} for host network"
  318. fail_msg: "{{ fail_dhcp_range }} for host network"
  319. - name: Assert host_network_dhcp_end_range
  320. assert:
  321. that:
  322. - host_network_dhcp_end_range
  323. - host_network_dhcp_end_range | ipv4
  324. - host_network_dhcp_end_range != hpc_ip
  325. - host_network_dhcp_start_range != host_network_dhcp_end_range
  326. - dhcp_end_host == subnet
  327. - dhcp_start_host == dhcp_end_host
  328. success_msg: "{{ success_dhcp_range }} for host network"
  329. fail_msg: "{{ fail_dhcp_range }} for host network"
  330. - name: Set the mapping file value for host network
  331. set_fact:
  332. host_mapping_file: true
  333. when: host_mapping_file_path | length > 0
  334. - name: Assert valid mapping_file_path
  335. stat:
  336. path: "{{ host_mapping_file_path }}"
  337. when: host_mapping_file
  338. register: result_host_mapping_file
  339. - name: Valid mapping_file_path
  340. fail:
  341. msg: "{{ invalid_mapping_file_path }} for host_network"
  342. when: host_mapping_file and not result_host_mapping_file.stat.exists
  343. - name: Verify different nics
  344. assert:
  345. that:
  346. - public_nic != mngmnt_network_nic
  347. - mngmnt_network_nic != host_network_nic
  348. - public_nic != host_network_nic
  349. success_msg: "{{ success_msg_different_nics }}"
  350. fail_msg: "{{ fail_msg_different_nics }}"
  351. ########
  352. - name: Fetch the infiniband network ip, netmask and subnet
  353. set_fact:
  354. ib_ip: "{{ lookup('vars','ansible_'+ib_network_nic).ipv4.address }}"
  355. ib_netmask: "{{ lookup('vars','ansible_'+ib_network_nic).ipv4.netmask }}"
  356. ib_subnet: "{{ lookup('vars','ansible_'+ib_network_nic).ipv4.network }}"
  357. when: ib_switch_support
  358. - name: Check the subnet of infiniband network dhcp start range
  359. shell: |
  360. IFS=. read -r i1 i2 i3 i4 <<< "{{ ib_network_dhcp_start_range }}"
  361. IFS=. read -r m1 m2 m3 m4 <<< "{{ ib_netmask }}"
  362. printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
  363. args:
  364. warn: no
  365. register: dhcp_start_ib_result
  366. when: ib_switch_support
  367. changed_when: false
  368. - name: Set the start dhcp subnet for infiniband network
  369. set_fact:
  370. dhcp_start_ib: "{{ dhcp_start_ib_result.stdout }}"
  371. when: ib_switch_support
  372. - name: Check the subnet of dhcp end range for infiniband network
  373. shell: |
  374. IFS=. read -r i1 i2 i3 i4 <<< "{{ ib_network_dhcp_end_range }}"
  375. IFS=. read -r m1 m2 m3 m4 <<< "{{ ib_netmask }}"
  376. printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
  377. register: dhcp_end_ib_result
  378. when: ib_switch_support
  379. changed_when: false
  380. - name: Set the end dhcp subnet for infiniband network
  381. set_fact:
  382. dhcp_end_ib: "{{ dhcp_end_ib_result.stdout }}"
  383. when: ib_switch_support
  384. - name: Assert infiniband_net_dhcp_start_range
  385. assert:
  386. that:
  387. - ib_network_dhcp_start_range
  388. - ib_network_dhcp_start_range | ipv4
  389. - ib_network_dhcp_start_range != ib_ip
  390. - ib_network_dhcp_start_range != ib_network_dhcp_end_range
  391. - dhcp_start_ib == ib_subnet
  392. - dhcp_start_ib == dhcp_end_ib
  393. success_msg: "{{ success_dhcp_range }} for infiniband network"
  394. fail_msg: "{{ fail_dhcp_range }} for infiniband network"
  395. when: ib_switch_support
  396. - name: Assert infiniband_net_dhcp_end_range
  397. assert:
  398. that:
  399. - ib_network_dhcp_end_range
  400. - ib_network_dhcp_end_range | ipv4
  401. - ib_network_dhcp_end_range != ib_ip
  402. - ib_network_dhcp_start_range != ib_network_dhcp_end_range
  403. - dhcp_end_ib == ib_subnet
  404. - dhcp_start_ib == dhcp_end_ib
  405. success_msg: "{{ success_dhcp_range }} for infiniband network"
  406. fail_msg: "{{ fail_dhcp_range }} for infiniband network"
  407. when: ib_switch_support
  408. - name: Verify different nics with infiniband nic
  409. assert:
  410. that:
  411. - public_nic != ib_network_nic
  412. - mngmnt_network_nic != ib_network_nic
  413. - ib_network_nic != host_network_nic
  414. success_msg: "{{ success_msg_different_nics_ib }}"
  415. fail_msg: "{{ fail_msg_different_nics_ib }}"
  416. when: ib_switch_support