buluma.logrotate

Ansible Role Logrotate

This role helps you install and set up logrotate on your system, which is a tool for managing and rotating log files.

GitHub Version Issues Pull Requests Downloads
github Version Issues PullRequests Ansible Role

Example Playbook

Here’s an example taken from molecule/default/converge.yml. This example is tested every time there is a change made to the code.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true

  vars:
    logrotate_frequency: daily
    logrotate_keep: 7
    logrotate_compress: true
    logrotate_entries:
      - name: example
        path: "/var/log/example/*.log"
      # More logrotate entries can be added here.
  
  roles:
    - role: buluma.logrotate

Before running this code, you need to set up your machine. In CI, this setup is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: buluma.bootstrap
    - role: buluma.cron

  post_tasks:
    - name: Create log directory
      ansible.builtin.file:
        path: "{{ item }}"
        state: directory
        mode: "0755"
      loop:
        - /var/log/example
        # More directories can be added here.

    - name: Create log file
      ansible.builtin.copy:
        dest: "{{ item }}"
        content: "example"
        mode: "0644"
      loop:
        - /var/log/example/app.log
        # More log files can be added here.

For further details and examples, check this complete guide on how to use these roles.

Role Variables

The default values for the logrotate settings are defined in defaults/main.yml:

---
# defaults for logrotate

logrotate_frequency: weekly  # Frequency of log rotation.
logrotate_keep: 4            # Number of rotated files to keep.
logrotate_compress: true      # Whether to compress logs after rotation.
logrotate_service_state: "started"  # Desired state of logrotate service.
logrotate_service_enabled: true      # Whether to enable logrotate service.

Requirements

This role depends on specific Python packages listed in requirements.txt.

State of Used Roles

The following roles set up your system. You can use alternative methods to prepare your system.

Requirement GitHub Version
buluma.bootstrap Ansible Molecule Version
buluma.cron Ansible Molecule Version
buluma.epel Ansible Molecule Version

Context

This role works together with other compatible roles. You can find more information about these roles here.

Compatibility

This role has been tested on several container images. The minimum Ansible version required is 2.12.

If you encounter any issues, please report them on GitHub.

Changelog

For the history of changes made to this role, see here.

License

This role is licensed under the Apache-2.0.

Author Information

Created by Shadow Walker.

Informazioni sul progetto

Install and configure logrotate on your system.

Installa
ansible-galaxy install buluma.logrotate
Licenza
apache-2.0
Download
67.4k
Proprietario
DevOps Engineer