password_config.yml 9.4 KB

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