test.yml 703 Bytes
---
- hosts: all
  become: True
  vars:
    logrotate_scripts:
      - name: nginx-options
        path: /var/log/nginx/options.log
        options:
          - daily

      - name: nginx-scripts
        path: /var/log/nginx/scripts.log
        scripts:
          postrotate: "echo test"

      - name: multiple-paths
        paths:
          - /var/log/nginx/options.log
          - /var/log/nginx/scripts.log

  roles:
    - ansible-logrotate

  tasks:
    - name: Verify logrotate config check passes
      shell: logrotate -d "{{ logrotate_conf_dir }}{{ item.name }}"
      with_items: "{{ logrotate_scripts }}"
      register: logrotate_tests
      failed_when: "'error' in logrotate_tests.stderr"