password_config.yml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 in grafana_password '
  113. - '"\\" not in grafana_password '
  114. - '"\"" not in grafana_password '
  115. - " \"'\" not in grafana_password "
  116. no_log: true
  117. rescue:
  118. - name: grafana credentials validation check
  119. fail:
  120. msg: "{{ fail_msg_grafana_credentials }}"
  121. - name: Assert username and password for ethernet switches
  122. block:
  123. - name: Verify ethernet_switch_username and ethernet_switch_password are not empty
  124. assert:
  125. that:
  126. - ethernet_switch_username | length >= min_username_length
  127. - ethernet_switch_username | length < max_length
  128. - '"-" not in ethernet_switch_username '
  129. - '"\\" not in ethernet_switch_username '
  130. - '"\"" not in ethernet_switch_username '
  131. - " \"'\" not in ethernet_switch_username "
  132. - ethernet_switch_password | length > min_username_length | int - 1
  133. - ethernet_switch_password | length < max_length | int + 1
  134. - '"-" not in ethernet_switch_password '
  135. - '"\\" not in ethernet_switch_password '
  136. - '"\"" not in ethernet_switch_password '
  137. - " \"'\" not in ethernet_switch_password "
  138. no_log: true
  139. rescue:
  140. - name: ethernet switch credentials validation check
  141. fail:
  142. msg: "{{ fail_msg_ethernet_credentials }}"
  143. when: ethernet_switch_support
  144. - name: Assert username and password for IB switches
  145. block:
  146. - name: Assert ib_username and ib_password
  147. assert:
  148. that:
  149. - ib_username | length >= min_username_length
  150. - ib_username | length < max_length
  151. - '"-" not in ib_username '
  152. - '"\\" not in ib_username '
  153. - '"\"" not in ib_username '
  154. - " \"'\" not in ib_username "
  155. - ib_password | length > min_username_length | int - 1
  156. - ib_password | length < max_length | int + 1
  157. - '"-" not in ib_password '
  158. - '"\\" not in ib_password '
  159. - '"\"" not in ib_password '
  160. - " \"'\" not in ib_password "
  161. no_log: true
  162. rescue:
  163. - name: IB switch credentials validation check
  164. fail:
  165. msg: "{{ fail_msg_ib_credentials }}"
  166. when: ib_switch_support
  167. - name: Assert username and password for powervault me4
  168. block:
  169. - name: Assert powervault_me4_username and powervault_me4_password
  170. assert:
  171. that:
  172. - powervault_me4_username | length >= min_username_length
  173. - powervault_me4_username | length < max_length
  174. - '"-" not in powervault_me4_username '
  175. - '"\\" not in powervault_me4_username '
  176. - '"\"" not in powervault_me4_username '
  177. - " \"'\" not in powervault_me4_username "
  178. - powervault_me4_password | length > min_length | int - 1
  179. - powervault_me4_password | length < max_length | int + 1
  180. - '"-" not in powervault_me4_password '
  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. - powervault_me4_password | regex_search('^(?=.*[a-z]).+$')
  188. - powervault_me4_password | regex_search('^(?=.*[A-Z]).+$')
  189. - powervault_me4_password | regex_search('^(?=.*\\d).+$')
  190. - powervault_me4_password | regex_search('^(?=.*[!#$%&()*+/:;=>?@^_`{} ~]).+$')
  191. no_log: true
  192. rescue:
  193. - name: Powervault me4 credentials validation check
  194. fail:
  195. msg: "{{ fail_msg_me4_credentials }}"
  196. when: powervault_support
  197. - name: Assert directory_manager_password
  198. assert:
  199. that:
  200. - directory_manager_password | length > min_length | int - 1
  201. - directory_manager_password | length < max_length | int + 1
  202. - '"-" not in directory_manager_password '
  203. - '"\\" not in directory_manager_password '
  204. - '"\"" not in directory_manager_password '
  205. - " \"'\" not in directory_manager_password "
  206. success_msg: "{{ success_msg_dir_manager_password }}"
  207. fail_msg: "{{ fail_msg_dir_manager_password }}"
  208. when: enable_security_support
  209. - name: Assert ipa_admin_password
  210. assert:
  211. that:
  212. - ipa_admin_password | length > min_length | int - 1
  213. - ipa_admin_password | length < max_length | int + 1
  214. - '"-" not in ipa_admin_password '
  215. - '"\\" not in ipa_admin_password '
  216. - '"\"" not in ipa_admin_password '
  217. - " \"'\" not in ipa_admin_password "
  218. success_msg: "{{ success_msg_ipa_admin_pwd }}"
  219. fail_msg: "{{ fail_msg_ipa_admin_pwd }}"
  220. when: enable_security_support
  221. - name: Create ansible vault key
  222. set_fact:
  223. vault_key: "{{ lookup('password', '/dev/null chars=ascii_letters') }}"
  224. when: "'$ANSIBLE_VAULT;' not in config_content.stdout"
  225. - name: Save vault key
  226. copy:
  227. dest: "{{ vault_filename }}"
  228. content: |
  229. {{ vault_key }}
  230. owner: root
  231. force: yes
  232. mode: "{{ vault_file_perm }}"
  233. when: "'$ANSIBLE_VAULT;' not in config_content.stdout"
  234. - name: Encrypt input config file
  235. command: >-
  236. ansible-vault encrypt {{ login_vars_filename }}
  237. --vault-password-file {{ vault_filename }}
  238. changed_when: false
  239. - name: Update login_vars.yml permission
  240. file:
  241. path: "{{ login_vars_filename }}"
  242. mode: "{{ file_perm }}"