All Projects → robertdebock → ansible-role-logrotate

robertdebock / ansible-role-logrotate

Licence: Apache-2.0 License
Install and configure logrotate on your system.

Programming Languages

Jinja
831 projects

Projects that are alternatives of or similar to ansible-role-logrotate

Ansible Role Bootstrap
Prepare your system to be managed by Ansible.
Stars: ✭ 106 (+715.38%)
Mutual labels:  playbook, molecule, tox
ansible-role-fail2ban
Install and configure fail2ban on your system.
Stars: ✭ 42 (+223.08%)
Mutual labels:  playbook, molecule, tox
ansible-role-dsvpn
Install and configure dsvpn on your system.
Stars: ✭ 18 (+38.46%)
Mutual labels:  playbook, molecule, tox
ansible-role-tomcat
Install and configure tomcat on your system.
Stars: ✭ 34 (+161.54%)
Mutual labels:  playbook, molecule, tox
ansible-role-dns
Install and configure dns on your system.
Stars: ✭ 39 (+200%)
Mutual labels:  playbook, molecule, tox
ansible-role-rsyslog
Install and configure rsyslog on your system.
Stars: ✭ 14 (+7.69%)
Mutual labels:  playbook, molecule, tox
Ansible Node Exporter
Provision basic metrics exporter for prometheus monitoring tool
Stars: ✭ 263 (+1923.08%)
Mutual labels:  molecule, tox
Ansible Grafana
Platform for analytics and monitoring
Stars: ✭ 340 (+2515.38%)
Mutual labels:  molecule, tox
Ansible Prometheus
Deploy Prometheus monitoring system
Stars: ✭ 758 (+5730.77%)
Mutual labels:  molecule, tox
Ansible Alertmanager
Deploy Prometheus Alertmanager service
Stars: ✭ 93 (+615.38%)
Mutual labels:  molecule, tox
ansible-snmp-exporter
Provision SNMP metrics exporter for prometheus monitoring
Stars: ✭ 18 (+38.46%)
Mutual labels:  molecule, tox
ansible-fluentd
Provision fluentd log collector
Stars: ✭ 20 (+53.85%)
Mutual labels:  molecule, tox
ansible-blackbox-exporter
Blackbox prober exporter
Stars: ✭ 60 (+361.54%)
Mutual labels:  molecule, tox
ansible-haproxy
Ansible HAproxy role for Unified OpenStack Installer and others.
Stars: ✭ 35 (+169.23%)
Mutual labels:  playbook, molecule
ansible-coredns
Ansible provisioning of CoreDNS
Stars: ✭ 25 (+92.31%)
Mutual labels:  molecule, tox
zimbra
Ansible role to install and configure Zimbra Collaboration Open Source Edition
Stars: ✭ 33 (+153.85%)
Mutual labels:  playbook
tox-ini-fmt
Formats your tox.ini files
Stars: ✭ 19 (+46.15%)
Mutual labels:  tox
spid-ansible-shibboleth-example
Service provider di base con autenticazione SPID
Stars: ✭ 21 (+61.54%)
Mutual labels:  playbook
molecule-openstack
Molecule OpenStack Driver
Stars: ✭ 15 (+15.38%)
Mutual labels:  molecule
ansible-kafka
Ansible role for installing and configuring Apache Kafka on RedHat and Debian platforms.
Stars: ✭ 56 (+330.77%)
Mutual labels:  molecule

logrotate

Install and configure logrotate on your system.

GitHub GitLab Quality Downloads Version
github gitlab quality downloads Version

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: converge
  hosts: all
  become: yes
  gather_facts: yes

  vars:
    logrotate_frequency: daily
    logrotate_keep: 7
    logrotate_compress: yes
    logrotate_entries:
      - name: example
        path: "/var/log/example/*.log"
      - name: example-frequency
        path: "/var/log/example-frequency/*.log"
        frequency: weekly
      - name: example-keep
        path: "/var/log/example-keep/*.log"
        keep: 14
      - name: example-compress
        path: "/var/log/example-compress/*.log"
        compress: yes
      - name: example-script
        path: "/var/log/example-script/*.log"
        postrotate: killall -HUP some_process_name
      - name: btmp
        path: /var/log/btmp
        missingok: yes
        frequency: monthly
        create: yes
        create_mode: "0660"
        create_user: root
        create_group: utmp
        keep: 1
      - name: wtmp
        path: /var/log/wtmp
        missingok: yes
        frequency: monthly
        create: yes
        create_mode: "0664"
        create_user: root
        create_group: utmp
        minsize: 1M
        keep: 1
      - name: dnf
        path: /var/log/hawkey.log
        missingok: yes
        notifempty: yes
        keep: 4
        frequency: weekly
        create: yes
      - name: example-sharedscripts
        path: "/var/log/example-sharedscripts/*.log"
        sharedscripts: yes

  roles:
    - role: robertdebock.logrotate

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: prepare
  hosts: all
  become: yes
  gather_facts: no

  roles:
    - role: robertdebock.bootstrap
    - role: robertdebock.cron

  post_tasks:
    - name: create log directory
      ansible.builtin.file:
        path: "{{ item }}"
        state: directory
      loop:
        - /var/log/example
        - /var/log/example-frequency
        - /var/log/example-keep
        - /var/log/example-compress
        - /var/log/example-script
        - /var/log/example-sharedscripts

    - name: create log file
      ansible.builtin.copy:
        dest: "{{ item }}"
        content: "example"
      loop:
        - /var/log/example/app.log
        - /var/log/example-frequency/app.log
        - /var/log/example-keep/app.log
        - /var/log/example-compress/app.log
        - /var/log/example-script/app.log
        - /var/log/example-sharedscripts/app.log
        - /var/log/btmp
        - /var/log/wtmp
        - /var/log/hawkey.log

Also see a full explanation and example on how to use these roles.

Role Variables

The default values for the variables are set in defaults/main.yml:

---
# defaults file for logrotate

# How often to rotate logs, either daily, weekly or monthly.
logrotate_frequency: weekly

# How many files to keep.
logrotate_keep: 4

# Should rotated logs be compressed??
logrotate_compress: yes

# Use date extension on log file names
logrotate_dateext: no

# User/Group for rotated log files (Loaded by OS-Specific vars if found, or and can be set manually)
logrotate_user: "{{ _logrotate_user[ansible_distribution] | default(_logrotate_user['default'] ) }}"
logrotate_group: "{{ _logrotate_group[ansible_distribution] | default(_logrotate_group['default'] ) }}"

Requirements

Status of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab
robertdebock.bootstrap Build Status GitHub Build Status GitLab
robertdebock.cron Build Status GitHub Build Status GitLab

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles: dependencies

Compatibility

This role has been tested on these container images:

container tags
alpine all
amazon Candidate
el all
debian all
fedora all
opensuse all
ubuntu all

The minimum version of Ansible required is 2.10, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub

License

Apache-2.0

Author Information

Robert de Bock

Please consider sponsoring me.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].