test_snoopy.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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: OMNIA_1.2_MS_TC_001
  16. hosts: localhost
  17. connection: local
  18. vars_files:
  19. - ../input_params/base_vars.yml
  20. - test_vars/test_snoopy_vars.yml
  21. gather_subset:
  22. - 'min'
  23. tags: VERIFY_OMNIA_02
  24. tasks:
  25. - name: Check OS Version
  26. assert:
  27. that:
  28. - 'ansible_distribution == "{{ os_name_rocky }}"'
  29. success_msg: "{{ check_os_success_msg }}"
  30. fail_msg: "{{ check_os_fail_msg }}"
  31. tags: Check_OS
  32. # OMNIA_1.2_snoopy_TC_001
  33. # Test case to Validate /var/log is available or not
  34. - name: Find /var/log all directories, exclude nginx and mysql
  35. find:
  36. paths: /var/log
  37. recurse: no
  38. file_type: directory
  39. excludes: 'nginx,mysql'
  40. register: islog_available
  41. - name: Verify log path and related directories available
  42. assert:
  43. that:
  44. - "islog_available.matched > 0 "
  45. success_msg: "{{ snoopy_log_path_success_msg }}"
  46. fail_msg: "{{ snoopy_log_path_fail_msg }}"
  47. # OMNIA_1.2_snoopy_TC_002
  48. # Test case to Validate snoopy is enabled in /var/log/secure
  49. - name: Test case to Validate snoopy is enabled in /var/log/secure
  50. shell: cat /var/log/secure | grep snoopy | wc -l
  51. register: secure_snoopy
  52. - name: Verify snoopy is enabled in /var/log/secure
  53. assert:
  54. that:
  55. - "secure_snoopy.stdout != 0"
  56. success_msg: "{{ secure_snoopy_enable_success_msg }}"
  57. fail_msg: "{{ secure_snoopy_enable_fail_msg }}"
  58. # OMNIA_1.2_snoopy_TC_003
  59. # Test case to Validate snoopy is enabled in /var/log/messages
  60. - name: Test case to Validate snoopy is enabled in /var/log/messages
  61. shell: cat /var/log/messages | grep snoopy | wc -l
  62. register: messages_snoopy
  63. - name: Verify snoopy is enabled in /var/log/messages
  64. assert:
  65. that:
  66. - "messages_snoopy.stdout != 0"
  67. success_msg: "{{ messages_snoopy_enable_success_msg }}"
  68. fail_msg: "{{ messages_snoopy_enable_fail_msg }}"
  69. # OMNIA_1.2_snoopy_TC_004
  70. # Test case to validate snoopy is disabled in MS
  71. - name: Disable the snoopy in log files
  72. shell: snoopy-disable
  73. register: snoopy_disable
  74. - name: Verify snoopy is disabled or not
  75. assert:
  76. that:
  77. - snoopy_disable.stdout | regex_search( "{{ Disabled }}")
  78. success_msg: "{{ snoopy_disabled_success_msg }}"
  79. fail_msg: "{{ snoopy_disabled_fail_msg }}"
  80. # OMNIA_1.2_snoopy_TC_005
  81. # Test case to Validate snoopy is disabled in /var/log/secure
  82. - name: Test case to Validate snoopy is enabled in /var/log/secure
  83. shell: cat /var/log/secure | grep snoopy | wc -l
  84. register: secure_snoopy_disabled
  85. - name: Verify snoopy is disabled in /var/log/secure
  86. assert:
  87. that:
  88. - "secure_snoopy_disabled.stdout > secure_snoopy.stdout"
  89. success_msg: "{{ secure_snoopy_disabled_success_msg }}"
  90. fail_msg: "{{ secure_snoopy_disabled_fail_msg }}"
  91. # OMNIA_1.2_snoopy_TC_006
  92. # Test case to validate snoopy is enable in MS
  93. - name: Enabled the snoopy in log files
  94. shell: snoopy-enable
  95. register: snoopy_enable
  96. - name: Verify snoopy is Enabled or not
  97. assert:
  98. that:
  99. - snoopy_enable.stdout | regex_search( "{{ Enabled }}")
  100. success_msg: "{{ snoopy_enable_success_msg }}"
  101. fail_msg: "{{ snoopy_enable_fail_msg }}"