test_psacct.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. gather_facts: true
  19. vars_files:
  20. - ../input_params/base_vars.yml
  21. - test_vars/test_psacct_vars.yml
  22. gather_subset:
  23. - 'min'
  24. tags: VERIFY_OMNIA_02
  25. tasks:
  26. - name: Check OS Version
  27. assert:
  28. that:
  29. - 'ansible_distribution == "{{ os_name_rocky }}"'
  30. success_msg: "{{ check_os_success_msg }}"
  31. fail_msg: "{{ check_os_fail_msg }}"
  32. tags: Check_OS
  33. # OMNIA_1.2_psacct_TC_001
  34. # Test case to Verify the enable psacct service
  35. - name: Enable the psacct service
  36. shell: systemctl enable --now psacct
  37. register: psacct_enable
  38. when:
  39. - 'ansible_distribution == "{{ os_name_rocky }}"'
  40. - name: Verify psacct service whether enabled or not
  41. assert:
  42. that:
  43. - psacct_enable.stderr | regex_search( "{{ psacct_enabled }}")
  44. success_msg: "{{ psacct_enable_success_msg }}"
  45. fail_msg: "{{ psacct_disable_fail_msg }}"
  46. # OMNIA_1.2_psacct_TC_002
  47. # Test case to Check and Start psacct Service
  48. - name: Check the psacct service status
  49. shell: systemctl status psacct.service
  50. register: psacct_status
  51. when:
  52. - 'ansible_distribution == "{{ os_name_rocky }}"'
  53. - name: Verify psacct service is started or not
  54. assert:
  55. that:
  56. - psacct_status.stdout | regex_search( "{{ psacct_active }}")
  57. success_msg: "{{ psacct_service_success_msg }}"
  58. fail_msg: "{{ psacct_service_fail_msg }}"
  59. # OMNIA_1.2_psacct_TC_003
  60. # Test case to Verify the Package Installation
  61. - name: Check the psacct Package Installation
  62. shell: rpm -qa | grep -i psacct
  63. register: psacct_package
  64. when:
  65. - 'ansible_distribution == "{{ os_name_rocky }}"'
  66. - name: Verify psacct Package whether installed or not
  67. assert:
  68. that:
  69. - psacct_package.stdout | regex_search( "psacct-6.6.3-4.el8.x86_64")
  70. success_msg: "{{ psacct_package_success_msg }}"
  71. fail_msg: "{{ psacct_package_fail_msg }}"
  72. # OMNIA_1.2_psacct_TC_004
  73. # Test case to Verify the disable psacct service
  74. - name: Disable the psacct service
  75. shell: systemctl disable psacct.service
  76. register: psacct_disable
  77. when:
  78. - 'ansible_distribution == "{{ os_name_rocky }}"'
  79. - name: Enable the psacct service
  80. shell: systemctl enable --now psacct
  81. register: psacct_enable
  82. when:
  83. - 'ansible_distribution == "{{ os_name_rocky }}"'
  84. - name: Verify psacct service whether disabled or not
  85. assert:
  86. that:
  87. - psacct_disable.stderr | regex_search( "{{ psacct_disabled }}")
  88. success_msg: "{{ psacct_disable_success_msg }}"
  89. fail_msg: "{{ psacct_disable_fail_msg }}"
  90. # OMNIA_1.2_psacct_TC_005
  91. # Test case to Verify ac and sa version
  92. - name: Check the ac version
  93. shell: ac -V
  94. register: ac_version
  95. when:
  96. - 'ansible_distribution == "{{ os_name_rocky }}"'
  97. - name: Check the as version
  98. shell: sa -V
  99. register: sa_version
  100. when:
  101. - 'ansible_distribution == "{{ os_name_rocky }}"'
  102. - name: Verify ac version
  103. assert:
  104. that:
  105. - ac_version.stdout | regex_search( "{{ psacct_ac_version }}")
  106. success_msg: "{{ psacct_ac_version_success_msg }}"
  107. fail_msg: "{{ psacct_ac_version_fail_msg }}"
  108. - name: Verify sa version
  109. assert:
  110. that:
  111. - sa_version.stdout | regex_search( "{{ psacct_sa_version }}")
  112. success_msg: "{{ psacct_sa_version_success_msg }}"
  113. fail_msg: "{{ psacct_sa_version_fail_msg }}"
  114. # OMNIA_1.2_psacct_TC_006
  115. # Test case to Check Package details of ac and sa utility
  116. - name: find the complete path of ac
  117. shell: which ac
  118. register: ac_path
  119. when:
  120. - 'ansible_distribution == "{{ os_name_rocky }}"'
  121. - name: check the package details of ac utility
  122. shell: rpm -qf {{ ac_path.stdout }}
  123. register: ac_utility
  124. when:
  125. - 'ansible_distribution == "{{ os_name_rocky }}"'
  126. - name: Verify package details of ac utility
  127. assert:
  128. that:
  129. - ac_utility.stdout | regex_search( "{{ psacct_ac_sa_utility }}")
  130. success_msg: "{{ psacct_ac_utility_success_msg }}"
  131. fail_msg: "{{ psacct_ac_utility_fail_msg }}"
  132. - name: find the complete path of sa
  133. shell: which sa
  134. register: sa_path
  135. when:
  136. - 'ansible_distribution == "{{ os_name_rocky }}"'
  137. - name: check the package details of sa utility
  138. shell: rpm -qf {{ sa_path.stdout }}
  139. register: sa_utility
  140. when:
  141. - 'ansible_distribution == "{{ os_name_rocky }}"'
  142. - name: Verify package details of sa utility
  143. assert:
  144. that:
  145. - sa_utility.stdout | regex_search( "{{ psacct_ac_sa_utility }}")
  146. success_msg: "{{ psacct_sa_utility_success_msg }}"
  147. fail_msg: "{{ psacct_sa_utility_fail_msg }}"