{"id":15140798,"url":"https://github.com/robertdebock/ansible-role-logrotate","last_synced_at":"2025-06-21T17:03:17.264Z","repository":{"id":37455649,"uuid":"177800530","full_name":"robertdebock/ansible-role-logrotate","owner":"robertdebock","description":"Install and configure logrotate on your system.","archived":false,"fork":false,"pushed_at":"2025-03-06T16:10:03.000Z","size":237,"stargazers_count":51,"open_issues_count":8,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-21T17:02:30.680Z","etag":null,"topics":["ansible","logrotate","molecule","monitoring","playbook","system","tox"],"latest_commit_sha":null,"homepage":"https://robertdebock.nl/","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertdebock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"robertdebock"}},"created_at":"2019-03-26T14:04:37.000Z","updated_at":"2025-05-09T22:10:53.000Z","dependencies_parsed_at":"2023-02-15T07:46:37.419Z","dependency_job_id":"ae60e40c-4142-4600-a002-2d0d571eb4ee","html_url":"https://github.com/robertdebock/ansible-role-logrotate","commit_stats":{"total_commits":344,"total_committers":8,"mean_commits":43.0,"dds":"0.20639534883720934","last_synced_commit":"cda13016882f54740f72c92648574c126b199138"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"purl":"pkg:github/robertdebock/ansible-role-logrotate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-logrotate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-logrotate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-logrotate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-logrotate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertdebock","download_url":"https://codeload.github.com/robertdebock/ansible-role-logrotate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-logrotate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261162061,"owners_count":23118219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","logrotate","molecule","monitoring","playbook","system","tox"],"created_at":"2024-09-26T08:41:23.932Z","updated_at":"2025-06-21T17:03:12.135Z","avatar_url":"https://github.com/robertdebock.png","language":"Jinja","funding_links":["https://github.com/sponsors/robertdebock"],"categories":[],"sub_categories":[],"readme":"# [Ansible role logrotate](#logrotate)\n\nInstall and configure logrotate on your system.\n\n|GitHub|GitLab|Downloads|Version|\n|------|------|---------|-------|\n|[![github](https://github.com/robertdebock/ansible-role-logrotate/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-logrotate/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-logrotate/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-logrotate)|[![downloads](https://img.shields.io/ansible/role/d/robertdebock/logrotate)](https://galaxy.ansible.com/robertdebock/logrotate)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-logrotate.svg)](https://github.com/robertdebock/ansible-role-logrotate/releases/)|\n\n## [Example Playbook](#example-playbook)\n\nThis example is taken from [`molecule/default/converge.yml`](https://github.com/robertdebock/ansible-role-logrotate/blob/master/molecule/default/converge.yml) and is tested on each push, pull request and release.\n\n```yaml\n---\n- name: Converge\n  hosts: all\n  become: true\n  gather_facts: true\n\n  vars:\n    logrotate_frequency: daily\n    logrotate_keep: 7\n    logrotate_compress: true\n    logrotate_entries:\n      - name: example\n        path: \"/var/log/example/*.log\"\n      - name: example-frequency\n        path: \"/var/log/example-frequency/*.log\"\n        frequency: weekly\n      - name: example-keep\n        path: \"/var/log/example-keep/*.log\"\n        keep: 14\n      - name: example-compress\n        path: \"/var/log/example-compress/*.log\"\n        compress: true\n      - name: example-copylog\n        path: \"/var/log/example-copylog/*.log\"\n        copylog: true\n      - name: example-copytruncate\n        path: \"/var/log/example-copytruncate/*.log\"\n        copytruncate: true\n      - name: example-delaycompress\n        path: \"/var/log/example-delaycompress/*.log\"\n        delaycompress: true\n      - name: example-script\n        path: \"/var/log/example-script/*.log\"\n        postrotate: killall -HUP some_process_name\n      - name: btmp\n        path: /var/log/btmp\n        missingok: true\n        frequency: monthly\n        create: true\n        create_mode: \"0660\"\n        create_user: root\n        create_group: utmp\n        dateext: true\n        dateformat: \"-%Y-%m-%d\"\n        keep: 1\n      - name: wtmp\n        path: /var/log/wtmp\n        missingok: true\n        frequency: monthly\n        create: true\n        create_mode: \"0664\"\n        create_user: root\n        create_group: utmp\n        minsize: 1M\n        maxsize: 128M\n        dateext: true\n        dateformat: \"-%Y%m%d\"\n        keep: 1\n      - name: dnf\n        path: /var/log/hawkey.log\n        missingok: true\n        notifempty: true\n        keep: 4\n        frequency: weekly\n        create: true\n      - name: example-sharedscripts\n        path: \"/var/log/example-sharedscripts/*.log\"\n        sharedscripts: true\n      - name: example-dateyesterday\n        state: present\n        path: \"/var/log/example-dateyesterday/*.log\"\n        dateyesterday: true\n      - name: example-absent\n        state: absent\n      # Negative numbers work on some distributions: `error: example-negative:10 bad rotation count '-1'\\`\n      # - name: example-negative\n      #   path: \"/var/log/example-keep-negative/*.log\"\n      #   keep: -1\n\n  roles:\n    - role: robertdebock.logrotate\n```\n\nThe machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/robertdebock/ansible-role-logrotate/blob/master/molecule/default/prepare.yml):\n\n```yaml\n---\n- name: Prepare\n  hosts: all\n  become: true\n  gather_facts: false\n\n  roles:\n    - role: robertdebock.bootstrap\n    - role: robertdebock.cron\n\n  post_tasks:\n    - name: Create log directory\n      ansible.builtin.file:\n        path: \"{{ item }}\"\n        state: directory\n        mode: \"0755\"\n      loop:\n        - /var/log/example\n        - /var/log/example-frequency\n        - /var/log/example-keep\n        - /var/log/example-compress\n        - /var/log/example-copylog\n        - /var/log/example-copytruncate\n        - /var/log/example-delaycompress\n        - /var/log/example-script\n        - /var/log/example-sharedscripts\n        - /var/log/example-dateyesterday\n\n    - name: Create log file\n      ansible.builtin.copy:\n        dest: \"{{ item }}\"\n        content: \"example\"\n        mode: \"0644\"\n      loop:\n        - /var/log/example/app.log\n        - /var/log/example-frequency/app.log\n        - /var/log/example-keep/app.log\n        - /var/log/example-compress/app.log\n        - /var/log/example-copylog/app.log\n        - /var/log/example-copytruncate/app.log\n        - /var/log/example-delaycompress/app.log\n        - /var/log/example-script/app.log\n        - /var/log/example-sharedscripts/app.log\n        - /var/log/example-dateyesterday/app.log\n        - /var/log/btmp\n        - /var/log/wtmp\n        - /var/log/hawkey.log\n```\n\nAlso see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles.\n\n## [Role Variables](#role-variables)\n\nThe default values for the variables are set in [`defaults/main.yml`](https://github.com/robertdebock/ansible-role-logrotate/blob/master/defaults/main.yml):\n\n```yaml\n---\n# defaults file for logrotate\n\n# How often to rotate logs, either daily, weekly or monthly.\nlogrotate_frequency: weekly\n\n# How many files to keep.\nlogrotate_keep: 4\n\n# Should rotated logs be compressed??\nlogrotate_compress: true\n\n# Use date extension on log file names\nlogrotate_dateext: false\n\n# User/Group for rotated log files (Loaded by OS-Specific vars if found, or and can be set manually)\nlogrotate_user: \"{{ _logrotate_user[ansible_distribution] | default(_logrotate_user['default']) }}\"\nlogrotate_group: \"{{ _logrotate_group[ansible_distribution] | default(_logrotate_group['default']) }}\"\n\n# Set the state of the service\nlogrotate_service_state: \"started\"\nlogrotate_service_enabled: true\n```\n\n## [Requirements](#requirements)\n\n- pip packages listed in [requirements.txt](https://github.com/robertdebock/ansible-role-logrotate/blob/master/requirements.txt).\n\n## [State of used roles](#state-of-used-roles)\n\nThe following roles are used to prepare a system. You can prepare your system in another way.\n\n| Requirement | GitHub | GitLab |\n|-------------|--------|--------|\n|[robertdebock.bootstrap](https://galaxy.ansible.com/robertdebock/bootstrap)|[![Build Status GitHub](https://github.com/robertdebock/ansible-role-bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bootstrap/actions)|[![Build Status GitLab](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap)|\n|[robertdebock.cron](https://galaxy.ansible.com/robertdebock/cron)|[![Build Status GitHub](https://github.com/robertdebock/ansible-role-cron/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-cron/actions)|[![Build Status GitLab](https://gitlab.com/robertdebock-iac/ansible-role-cron/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-cron)|\n\n## [Context](#context)\n\nThis role is a part of many compatible roles. Have a look at [the documentation of these roles](https://robertdebock.nl/) for further information.\n\nHere is an overview of related roles:\n![dependencies](https://raw.githubusercontent.com/robertdebock/ansible-role-logrotate/png/requirements.png \"Dependencies\")\n\n## [Compatibility](#compatibility)\n\nThis role has been tested on these [container images](https://hub.docker.com/u/robertdebock):\n\n|container|tags|\n|---------|----|\n|[Alpine](https://hub.docker.com/r/robertdebock/alpine)|all|\n|[Amazon](https://hub.docker.com/r/robertdebock/amazonlinux)|Candidate|\n|[EL](https://hub.docker.com/r/robertdebock/enterpriselinux)|9|\n|[Debian](https://hub.docker.com/r/robertdebock/debian)|all|\n|[Fedora](https://hub.docker.com/r/robertdebock/fedora)|all|\n|[Ubuntu](https://hub.docker.com/r/robertdebock/ubuntu)|all|\n\nThe minimum version of Ansible required is 2.12, tests have been done to:\n\n- The previous version.\n- The current version.\n- The development version.\n\nIf you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-logrotate/issues).\n\n## [License](#license)\n\n[Apache-2.0](https://github.com/robertdebock/ansible-role-logrotate/blob/master/LICENSE).\n\n## [Author Information](#author-information)\n\n[robertdebock](https://robertdebock.nl/)\n\nPlease consider [sponsoring me](https://github.com/sponsors/robertdebock).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertdebock%2Fansible-role-logrotate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertdebock%2Fansible-role-logrotate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertdebock%2Fansible-role-logrotate/lists"}