fetch_security_inputs.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. - name: Validate max_failures
  18. assert:
  19. that:
  20. - max_failures | int == max_failures_default_value
  21. success_msg: "{{ max_failures_success_msg }}"
  22. fail_msg: "{{ max_failures_fail_msg }}"
  23. - name: Validate failure_reset_interval
  24. assert:
  25. that:
  26. - failure_reset_interval | int
  27. - failure_reset_interval | int <= failure_reset_interval_max_value
  28. - failure_reset_interval | int >= failure_reset_interval_min_value
  29. success_msg: "{{ failure_reset_interval_success_msg }}"
  30. fail_msg: "{{ failure_reset_interval_fail_msg }}"
  31. - name: Validate lockout_duration
  32. assert:
  33. that:
  34. - lockout_duration | int
  35. - lockout_duration | int <= lockout_duration_max_value
  36. - lockout_duration | int >= lockout_duration_min_value
  37. success_msg: "{{ lockout_duration_success_msg }}"
  38. fail_msg: "{{ lockout_duration_fail_msg }}"
  39. - name: Validate session_timeout
  40. assert:
  41. that:
  42. - session_timeout | int
  43. - session_timeout | int <= session_timeout_max_value
  44. - session_timeout | int >= session_timeout_min_value
  45. success_msg: "{{ session_timeout_success_msg }}"
  46. fail_msg: "{{ session_timeout_fail_msg }}"
  47. - name: Validate alert_email_address
  48. assert:
  49. that:
  50. - email_search_key in alert_email_address
  51. - alert_email_address | length < email_max_length
  52. success_msg: "{{ alert_email_success_msg }}"
  53. fail_msg: "{{ alert_email_fail_msg }}"
  54. when: alert_email_address | length > 1
  55. - name: Warning - alert_email_address is empty
  56. debug:
  57. msg: "{{ alert_email_warning_msg }}"
  58. when: alert_email_address | length < 1
  59. - name: Prepare user list
  60. set_fact:
  61. user_list: "{{ lookup('vars', 'user').split()| unique | select| list }}"
  62. when: user | length > 1
  63. - name: validate user
  64. assert:
  65. that:
  66. - item is regex("^(?!-)[a-zA-Z]+[0-9-]*[@]((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$") or
  67. item is regex("(?!-)[a-zA-Z]+[0-9-]*$")
  68. success_msg: "{{ user_success_msg }}"
  69. fail_msg: "{{ user_fail_msg }}"
  70. with_items: "{{ user_list }}"
  71. when:
  72. - user | length > 1
  73. - name: Validate allow_deny
  74. assert:
  75. that:
  76. - allow_deny == 'Allow' or allow_deny == 'Deny'
  77. success_msg: "{{ allow_deny_success_msg }}"
  78. fail_msg: "{{ allow_deny_fail_msg }}"
  79. - name: Assert restrict_program_support
  80. assert:
  81. that:
  82. - restrict_program_support == true or restrict_program_support == false
  83. success_msg: "{{ restrict_program_support_success_msg }}"
  84. fail_msg: "{{ restrict_program_support_failure_msg }}"
  85. - name: Initialize variables for restrict_softwares
  86. set_fact:
  87. restrict_program_status: false
  88. disable_services: []
  89. - block:
  90. - name: The services needs to be disabled are appending to list
  91. set_fact:
  92. services_list: "{{ lookup('vars', 'restrict_softwares').split(',')| map('trim') | unique | select| list }}"
  93. - name: Assert restrict_softwares variable
  94. assert:
  95. that:
  96. - item == 'telnet' or
  97. item == 'lpd' or
  98. item == 'bluetooth' or
  99. item == 'rlogin' or
  100. item == 'rexec'
  101. success_msg: "{{ restrict_softwares_success_msg }}"
  102. fail_msg: "{{ restrict_softwares_failure_msg }}"
  103. failed_when: false
  104. with_items: "{{ services_list }}"
  105. - name: Creating a list for disabling services
  106. set_fact:
  107. disable_services: "{{ disable_services + [ item ] }}"
  108. when:
  109. - item == 'telnet' or
  110. item == 'lpd' or
  111. item == 'bluetooth' or
  112. item == 'rlogin' or
  113. item == 'rexec'
  114. with_items: "{{ services_list }}"
  115. - name: Setting restrict_program_status
  116. set_fact:
  117. restrict_program_status: true
  118. when:
  119. - disable_services | length > 0
  120. when: restrict_program_support