validate_login_node_vars.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 if omnia config file is encrypted
  16. command: cat {{ role_path }}/../../{{ config_filename }}
  17. changed_when: false
  18. register: config_content
  19. no_log: True
  20. delegate_to: localhost
  21. - name: Decrpyt omnia_config.yml
  22. command: >-
  23. ansible-vault decrypt {{ role_path }}/../../{{ config_filename }}
  24. --vault-password-file {{ role_path }}/../../{{ config_vaultname }}
  25. when: "'$ANSIBLE_VAULT;' in config_content.stdout"
  26. delegate_to: localhost
  27. - name: Include variable file omnia_config.yml
  28. include_vars: "{{ role_path }}/../../{{ config_filename }}"
  29. delegate_to: localhost
  30. no_log: True
  31. - name: Validate login node parameters when login_node_reqd is set to true
  32. fail:
  33. msg: "{{ input_config_failure_msg }} for login_node"
  34. when:
  35. - ( domain_name | length < 1 or
  36. realm_name | length < 1 or
  37. directory_manager_password | length < 1 or
  38. kerberos_admin_password | length < 1 )
  39. - login_node_required
  40. delegate_to: localhost
  41. - name: Verify the value of enable_secure_login_node
  42. assert:
  43. that:
  44. - enable_secure_login_node == true or enable_secure_login_node == false
  45. success_msg: "{{ secure_login_node_success_msg }}"
  46. fail_msg: "{{ secure_login_node_fail_msg }}"
  47. delegate_to: localhost
  48. - name: Login node to contain exactly 1 node
  49. assert:
  50. that:
  51. - "groups['login_node'] | length | int == 1"
  52. fail_msg: "{{ login_node_group_fail_msg }}"
  53. success_msg: "{{ login_node_group_success_msg }}"
  54. delegate_to: localhost
  55. - name: Validate the domain name
  56. assert:
  57. that:
  58. - domain_name is regex("^(?!-)[A-Za-z0-9-]+([\\-\\.]{1}[a-z0-9]+)*\\.[A-Za-z]{2,}$")
  59. success_msg: "{{ domain_name_success_msg }}"
  60. fail_msg: "{{ domain_name_fail_msg }}"
  61. delegate_to: localhost
  62. - name: Validate the realm name
  63. assert:
  64. that:
  65. - realm_name is regex("^(?!-)[A-Z0-9-]+([\\-\\.]{1}[a-z0-9]+)*\\.[A-Z]{2,}$")
  66. - '"." in realm_name'
  67. success_msg: "{{ realm_name_success_msg }}"
  68. fail_msg: "{{ realm_name_fail_msg }}"
  69. delegate_to: localhost
  70. - name: Assert directory_manager_password
  71. assert:
  72. that:
  73. - directory_manager_password | length > min_length | int - 1
  74. - directory_manager_password | length < max_length | int + 1
  75. - '"-" not in directory_manager_password '
  76. - '"\\" not in directory_manager_password '
  77. - '"\"" not in directory_manager_password '
  78. - " \"'\" not in directory_manager_password "
  79. success_msg: "{{ success_msg_directory_manager_password }}"
  80. fail_msg: "{{ fail_msg_directory_manager_password }}"
  81. delegate_to: localhost
  82. - name: Assert kerberos_admin_password
  83. assert:
  84. that:
  85. - kerberos_admin_password | length > min_length | int - 1
  86. - kerberos_admin_password | length < max_length | int + 1
  87. - '"-" not in kerberos_admin_password '
  88. - '"\\" not in kerberos_admin_password '
  89. - '"\"" not in kerberos_admin_password '
  90. - " \"'\" not in kerberos_admin_password "
  91. success_msg: "{{ success_msg_kerberos_admin_password }}"
  92. fail_msg: "{{ fail_msg_kerberos_admin_password }}"
  93. delegate_to: localhost
  94. - name: Encrypt input config file
  95. command: >-
  96. ansible-vault encrypt {{ role_path }}/../../{{ config_filename }}
  97. --vault-password-file {{ role_path }}/../../{{ config_vaultname }}
  98. changed_when: false
  99. delegate_to: localhost