add server_bootstrap role

This commit is contained in:
Kevin Heyer 2025-04-29 12:53:41 +02:00
parent 2115bbd726
commit 983e7ed3a1
8 changed files with 87 additions and 0 deletions

View file

View file

@ -0,0 +1,5 @@
---
# Default variables for logrotate configuration
server_bootstrap_logrotate_frequency: weekly
server_bootstrap_logrotate_rotate_count: 4
server_bootstrap_logrotate_compress: false

View file

@ -0,0 +1,5 @@
---
- name: Restart logrotate
ansible.builtin.service:
name: logrotate
state: restarted

View file

@ -0,0 +1,18 @@
---
galaxy_info:
author: Kevin Heyer
description: Role to install and configure logrotate on Debian systems
company: Kevin Heyer
license: MIT
min_ansible_version: "2.9"
platforms:
- name: Debian
versions:
- buster
- bullseye
galaxy_tags:
- logrotate
- debian
- logging
dependencies: []

View file

@ -0,0 +1,19 @@
---
- name: Install default packages
ansible.builtin.apt:
name: gnupg
state: present
- name: Ensure logrotate is installed
ansible.builtin.apt:
name: logrotate
state: present
- name: Deploy logrotate configuration
ansible.builtin.template:
src: logrotate.conf.j2
dest: /etc/logrotate.conf
owner: root
group: root
mode: '0644'
notify: Restart logrotate

View file

@ -0,0 +1,40 @@
# This file is managed by Ansible.
# Any manual changes will be overwritten.
# see "man logrotate" for details
# rotate log files weekly
{{ server_bootstrap_logrotate_frequency }}
# keep 4 weeks worth of backlogs
rotate {{ server_bootstrap_logrotate_rotate_count }}
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
{% if server_bootstrap_logrotate_compress %}
# compress the rotated files
compress
{% endif %}
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
# system-specific logs may be also be configured here