verify_login_inputs.yml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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: Check login_vars file is encrypted
  16. command: cat {{ login_vars_filename }}
  17. changed_when: false
  18. register: config_content
  19. no_log: true
  20. tags: init
  21. - name: Decrpyt login_vars.yml
  22. command: >-
  23. ansible-vault decrypt {{ login_vars_filename }}
  24. --vault-password-file {{ vault_filename }}
  25. changed_when: false
  26. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  27. tags: init
  28. - name: Include variable file login_vars.yml
  29. include_vars: "{{ login_vars_filename }}"
  30. no_log: true
  31. tags: init
  32. - name: Validate input parameters are not empty
  33. fail:
  34. msg: "{{ login_input_config_failure_msg }}"
  35. register: input_config_check
  36. when:
  37. - provision_password | length < 1 or
  38. cobbler_password | length < 1
  39. tags: [ validate, pxe, idrac ]
  40. - name: Validate security parameters when enable_security_support is set to true
  41. fail:
  42. msg: "{{ login_input_config_failure_msg }} for ipa server installation"
  43. tags: [ validate, security ]
  44. when:
  45. - ( ms_directory_manager_password | length < 1 or
  46. ms_kerberos_admin_password | length < 1 ) and
  47. enable_security_support
  48. - name: Assert provision credentials
  49. block:
  50. - name: Assert provision_password
  51. assert:
  52. that:
  53. - provision_password | length > min_length | int - 1
  54. - provision_password | length < max_length | int + 1
  55. - '"-" not in provision_password '
  56. - '"\\" not in provision_password '
  57. - '"\"" not in provision_password '
  58. - " \"'\" not in provision_password "
  59. no_log: true
  60. rescue:
  61. - name: Provision password validation check
  62. fail:
  63. msg: "{{ fail_msg_provision_password }}"
  64. tags: [ validate, pxe, idrac ]
  65. - name: Assert cobbler credentials
  66. block:
  67. - name: Assert cobbler_password
  68. assert:
  69. that:
  70. - cobbler_password | length > min_length | int - 1
  71. - cobbler_password | length < max_length | int + 1
  72. - '"-" not in cobbler_password '
  73. - '"\\" not in cobbler_password '
  74. - '"\"" not in cobbler_password '
  75. - " \"'\" not in cobbler_password "
  76. no_log: true
  77. rescue:
  78. - name: Cobbler password validation check
  79. fail:
  80. msg: "{{ fail_msg_cobbler_password }}"
  81. tags: [ validate, pxe ]
  82. - name: Assert idrac credentials
  83. block:
  84. - name: Assert idrac_username and idrac_password
  85. assert:
  86. that:
  87. - idrac_username | length >= min_username_length
  88. - idrac_username | length < max_length
  89. - '"-" not in idrac_username '
  90. - '"\\" not in idrac_username '
  91. - '"\"" not in idrac_username '
  92. - " \"'\" not in idrac_username "
  93. - idrac_password | length > min_username_length | int - 1
  94. - idrac_password | length < max_length | int + 1
  95. - '"-" not in idrac_password '
  96. - '"\\" not in idrac_password '
  97. - '"\"" not in idrac_password '
  98. - " \"'\" not in idrac_password "
  99. no_log: true
  100. rescue:
  101. - name: idrac credentials validation check
  102. fail:
  103. msg: "{{ fail_msg_idrac_credentials }}"
  104. when: device_support_status
  105. tags: [ validate, idrac ]
  106. - name: Assert grafana credentials
  107. block:
  108. - name: Assert grafana_username and grafana_username
  109. assert:
  110. that:
  111. - grafana_username | length >= min_length_grafana
  112. - grafana_username | length <= max_length
  113. - '"-" not in grafana_username '
  114. - '"\\" not in grafana_username '
  115. - '"\"" not in grafana_username '
  116. - " \"'\" not in grafana_username "
  117. - grafana_password | length >= min_length_grafana
  118. - grafana_password | length <= max_length
  119. - not grafana_password == 'admin'
  120. - '"-" not in grafana_password '
  121. - '"\\" not in grafana_password '
  122. - '"\"" not in grafana_password '
  123. - " \"'\" not in grafana_password "
  124. no_log: true
  125. rescue:
  126. - name: grafana credentials validation check
  127. fail:
  128. msg: "{{ fail_msg_grafana_credentials }}"
  129. tags: [ validate, monitoring ]
  130. - name: Assert username and password for ethernet switches
  131. block:
  132. - name: Verify ethernet_switch_username and ethernet_switch_password are not empty
  133. assert:
  134. that:
  135. - ethernet_switch_username | length >= min_username_length
  136. - ethernet_switch_username | length < max_length
  137. - '"-" not in ethernet_switch_username '
  138. - '"\\" not in ethernet_switch_username '
  139. - '"\"" not in ethernet_switch_username '
  140. - " \"'\" not in ethernet_switch_username "
  141. - ethernet_switch_password | length > min_username_length | int - 1
  142. - ethernet_switch_password | length < max_length | int + 1
  143. - '"-" not in ethernet_switch_password '
  144. - '"\\" not in ethernet_switch_password '
  145. - '"\"" not in ethernet_switch_password '
  146. - " \"'\" not in ethernet_switch_password "
  147. no_log: true
  148. rescue:
  149. - name: ethernet switch credentials validation check
  150. fail:
  151. msg: "{{ fail_msg_ethernet_credentials }}"
  152. when:
  153. - device_support_status
  154. - ethernet_switch_support
  155. tags: [ validate, network-device ]
  156. - name: Assert username and password for IB switches
  157. block:
  158. - name: Assert ib_username and ib_password
  159. assert:
  160. that:
  161. - ib_username | length >= min_username_length
  162. - ib_username | length < max_length
  163. - '"-" not in ib_username '
  164. - '"\\" not in ib_username '
  165. - '"\"" not in ib_username '
  166. - " \"'\" not in ib_username "
  167. - ib_password | length > min_username_length | int - 1
  168. - ib_password | length < max_length | int + 1
  169. - '"-" not in ib_password '
  170. - '"\\" not in ib_password '
  171. - '"\"" not in ib_password '
  172. - " \"'\" not in ib_password "
  173. no_log: true
  174. rescue:
  175. - name: IB switch credentials validation check
  176. fail:
  177. msg: "{{ fail_msg_ib_credentials }}"
  178. when:
  179. - device_support_status
  180. - ib_switch_support
  181. tags: [ validate, network-ib ]
  182. - name: Assert username and password for powervault me4
  183. block:
  184. - name: Assert powervault_me4_username and powervault_me4_password
  185. assert:
  186. that:
  187. - powervault_me4_username | length >= min_username_length
  188. - powervault_me4_username | length < max_length
  189. - '"-" not in powervault_me4_username '
  190. - '"\\" not in powervault_me4_username '
  191. - '"\"" not in powervault_me4_username '
  192. - " \"'\" not in powervault_me4_username "
  193. - powervault_me4_password | length > min_length | int - 1
  194. - powervault_me4_password | length < max_length | int + 1
  195. - '"-" not in powervault_me4_password '
  196. - '"," not in powervault_me4_password '
  197. - '"." not in powervault_me4_password '
  198. - '"<" not in powervault_me4_password '
  199. - '"\\" not in powervault_me4_password '
  200. - '"\"" not in powervault_me4_password '
  201. - " \"'\" not in powervault_me4_password "
  202. - powervault_me4_password | regex_search('^(?=.*[a-z]).+$')
  203. - powervault_me4_password | regex_search('^(?=.*[A-Z]).+$')
  204. - powervault_me4_password | regex_search('^(?=.*\\d).+$')
  205. - powervault_me4_password | regex_search('^(?=.*[!#$%&()*+/:;=>?@^_`{} ~]).+$')
  206. no_log: true
  207. rescue:
  208. - name: Powervault me4 credentials validation check
  209. fail:
  210. msg: "{{ fail_msg_me4_credentials }}"
  211. when:
  212. - device_support_status
  213. - powervault_support
  214. tags: [ validate, network-device ]
  215. - name: Assert ms_directory_manager_password
  216. assert:
  217. that:
  218. - ms_directory_manager_password | length > min_length | int - 1
  219. - ms_directory_manager_password | length < max_length | int + 1
  220. - '"-" not in ms_directory_manager_password '
  221. - '"\\" not in ms_directory_manager_password '
  222. - '"\"" not in ms_directory_manager_password '
  223. - " \"'\" not in ms_directory_manager_password "
  224. success_msg: "{{ success_msg_dir_manager_password }}"
  225. fail_msg: "{{ fail_msg_dir_manager_password }}"
  226. when: enable_security_support
  227. tags: [ validate, security ]
  228. - name: Assert ms_kerberos_admin_password
  229. assert:
  230. that:
  231. - ms_kerberos_admin_password | length > min_length | int - 1
  232. - ms_kerberos_admin_password | length < max_length | int + 1
  233. - '"-" not in ms_kerberos_admin_password '
  234. - '"\\" not in ms_kerberos_admin_password '
  235. - '"\"" not in ms_kerberos_admin_password '
  236. - " \"'\" not in ms_kerberos_admin_password "
  237. success_msg: "{{ success_msg_ipa_admin_pwd }}"
  238. fail_msg: "{{ fail_msg_ipa_admin_pwd }}"
  239. when: enable_security_support
  240. tags: [ validate, security ]
  241. - name: Create ansible vault key
  242. set_fact:
  243. vault_key: "{{ lookup('password', '/dev/null chars=ascii_letters') }}"
  244. when: "'$ANSIBLE_VAULT;' not in config_content.stdout"
  245. tags: init
  246. - name: Save vault key
  247. copy:
  248. dest: "{{ vault_filename }}"
  249. content: |
  250. {{ vault_key }}
  251. owner: root
  252. force: yes
  253. mode: "{{ vault_file_perm }}"
  254. when: "'$ANSIBLE_VAULT;' not in config_content.stdout"
  255. tags: init
  256. - name: Encrypt input config file
  257. command: >-
  258. ansible-vault encrypt {{ login_vars_filename }}
  259. --vault-password-file {{ vault_filename }}
  260. changed_when: false
  261. tags: init
  262. - name: Update login_vars.yml permission
  263. file:
  264. path: "{{ login_vars_filename }}"
  265. mode: "{{ file_perm }}"
  266. tags: init