fetch_security_inputs.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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: Include security variable file security_vars.yml
  16. include_vars: "{{ security_vars_filename }}"
  17. no_log: true
  18. tags: init
  19. - name: Validate input parameters of security vars are not empty
  20. fail:
  21. msg: "{{ input_security_failure_msg }}"
  22. register: input_base_check
  23. tags: [ validate, security ]
  24. when:
  25. - domain_name | length < 1 or
  26. realm_name | length < 1
  27. - name: Validate the domain name
  28. assert:
  29. that:
  30. - domain_name is regex("^(?!-)[A-Za-z0-9-]+([\\-\\.]{1}[a-z0-9]+)*\\.[A-Za-z]{2,}$")
  31. success_msg: "{{ dom_name_success_msg }}"
  32. fail_msg: "{{ dom_name_fail_msg }}"
  33. tags: [ validate, security ]
  34. - name: Validate the realm name
  35. assert:
  36. that:
  37. - realm_name is regex("^(?!-)[A-Z0-9-]+([\\-\\.]{1}[a-z0-9]+)*\\.[A-Z]{2,}$")
  38. - '"." in realm_name'
  39. success_msg: "{{ realm_success_msg }}"
  40. fail_msg: "{{ realm_fail_msg }}"
  41. tags: [ validate, security ]
  42. - name: Fetch the short hostname
  43. command: hostname -s
  44. register: short_hostname
  45. changed_when: false
  46. tags: [ validate, security ]
  47. - name: Verify the hostname is not blank in hostname
  48. fail:
  49. msg: " {{ hostname_blank_msg }}"
  50. when: short_hostname.stdout | length < 1
  51. tags: [ validate, security ]
  52. - name: Validate the host name
  53. assert:
  54. that:
  55. - short_hostname.stdout is regex(("^(([a-z]|[a-z][a-z0-9\-]*[a-z0-9])\.)*([a-z]|[a-z][a-z0-9\-]*[a-z0-9])$"))
  56. - short_hostname.stdout != "localhost"
  57. success_msg: "{{ server_hostname_success }}"
  58. fail_msg: "{{ server_hostname_fail }}"
  59. tags: [ validate, security ]
  60. - name: Fetch the domain name
  61. command: hostname -d
  62. register: domain_name_set
  63. changed_when: false
  64. tags: [ validate, security ]
  65. - name: Verify the domain name is not blank in hostname
  66. fail:
  67. msg: " {{ domain_name_blank_msg }}"
  68. when: domain_name_set.stdout | length < 1
  69. tags: [ validate, security ]
  70. - name: Set fact for the domain name in hostname
  71. set_fact:
  72. ms_domain_name: "{{ domain_name_set.stdout }}"
  73. tags: [ validate, security ]
  74. - name: Validate the domain name set on the host
  75. assert:
  76. that:
  77. - domain_name == ms_domain_name
  78. success_msg: "{{ server_domain_name_success }}"
  79. fail_msg: "{{ server_domain_name_fail }}"
  80. tags: [ validate, security ]
  81. - name: Get the hostname
  82. command: hostname
  83. register: machine_hostname
  84. changed_when: false
  85. tags: [ validate, security ]
  86. - name: Add host name in hosts file
  87. lineinfile:
  88. dest: "{{ hosts_file_path }}"
  89. line: "{{ public_ip }} {{ machine_hostname.stdout }}"
  90. state: present
  91. create: yes
  92. mode: "{{ hosts_file_mode }}"
  93. tags: [ validate, security ]
  94. - name: Validate max_failures
  95. assert:
  96. that:
  97. - max_failures | int == max_failures_default_value
  98. success_msg: "{{ max_failures_success_msg }}"
  99. fail_msg: "{{ max_failures_fail_msg }}"
  100. tags: [ validate, security ]
  101. - name: Validate failure_reset_interval
  102. assert:
  103. that:
  104. - failure_reset_interval | int
  105. - failure_reset_interval | int <= failure_reset_interval_max_value
  106. - failure_reset_interval | int >= failure_reset_interval_min_value
  107. success_msg: "{{ failure_reset_interval_success_msg }}"
  108. fail_msg: "{{ failure_reset_interval_fail_msg }}"
  109. tags: [ validate, security ]
  110. - name: Validate lockout_duration
  111. assert:
  112. that:
  113. - lockout_duration | int
  114. - lockout_duration | int <= lockout_duration_max_value
  115. - lockout_duration | int >= lockout_duration_min_value
  116. success_msg: "{{ lockout_duration_success_msg }}"
  117. fail_msg: "{{ lockout_duration_fail_msg }}"
  118. tags: [ validate, security ]
  119. - name: Validate session_timeout
  120. assert:
  121. that:
  122. - session_timeout | int
  123. - session_timeout | int <= session_timeout_max_value
  124. - session_timeout | int >= session_timeout_min_value
  125. success_msg: "{{ session_timeout_success_msg }}"
  126. fail_msg: "{{ session_timeout_fail_msg }}"
  127. tags: [ validate, security ]
  128. - name: Validate alert_email_address
  129. assert:
  130. that:
  131. - email_search_key in alert_email_address
  132. - alert_email_address | length < email_max_length
  133. success_msg: "{{ alert_email_success_msg }}"
  134. fail_msg: "{{ alert_email_fail_msg }}"
  135. tags: [ validate, security ]
  136. when: alert_email_address | length > 1
  137. - name: Warning - alert_email_address is empty
  138. debug:
  139. msg: "{{ alert_email_warning_msg }}"
  140. tags: security
  141. when: alert_email_address | length < 1