<def-group>



  <definition class="compliance" id="timer_logrotate_enabled" version="1">
    <metadata>
        <title>Enable logrotate Timer</title>
        
    <affected family="unix">
    <platform>Ubuntu 22.04</platform>
    </affected>
        <description>The logrotate timer should be enabled if possible.</description>
    </metadata>
    <criteria comment="package logrotate installed and timer logrotate is configured to start" operator="AND">
      <extend_definition comment="logrotate installed" definition_ref="package_logrotate_installed" />
      <criteria comment="timer logrotate is configured to start and is running" operator="AND">
        <criterion comment="logrotate is running" test_ref="test_timer_running_logrotate" />
        <criterion comment="multi-user.target wants logrotate" test_ref="test_multi_user_wants_logrotate" />
      </criteria>
    </criteria>
  </definition>

  <linux:systemdunitdependency_test check="all" check_existence="any_exist" comment="systemd test" id="test_multi_user_wants_logrotate" version="1">
    <linux:object object_ref="object_multi_user_target_for_logrotate_enabled" />
    <linux:state state_ref="state_systemd_logrotate_on"/>
  </linux:systemdunitdependency_test>
  <linux:systemdunitdependency_object id="object_multi_user_target_for_logrotate_enabled" comment="list of dependencies of multi-user.target" version="1">
    <linux:unit>multi-user.target</linux:unit>
  </linux:systemdunitdependency_object>
  <linux:systemdunitdependency_state id="state_systemd_logrotate_on" comment="logrotate listed at least once in the dependencies" version="1">
    <linux:dependency entity_check="at least one">logrotate.timer</linux:dependency>
  </linux:systemdunitdependency_state>

  <linux:systemdunitproperty_test id="test_timer_running_logrotate" check="at least one" check_existence="at_least_one_exists" comment="Test that the logrotate timer is running" version="1">
    <linux:object object_ref="obj_timer_running_logrotate"/>
    <linux:state state_ref="state_timer_running_logrotate"/>
  </linux:systemdunitproperty_test>
  <linux:systemdunitproperty_object id="obj_timer_running_logrotate" comment="Retrieve the ActiveState property of logrotate" version="1">
    <linux:unit operation="pattern match">logrotate\.timer</linux:unit>
    <linux:property>ActiveState</linux:property>
  </linux:systemdunitproperty_object>
  <linux:systemdunitproperty_state id="state_timer_running_logrotate" version="1" comment="logrotate is running">
      <linux:value>active</linux:value>
  </linux:systemdunitproperty_state>



</def-group>