add server_bootstrap role
This commit is contained in:
parent
2115bbd726
commit
983e7ed3a1
8 changed files with 87 additions and 0 deletions
0
roles/global/server_bootstrap/README.md
Normal file
0
roles/global/server_bootstrap/README.md
Normal file
5
roles/global/server_bootstrap/defaults/main.yml
Normal file
5
roles/global/server_bootstrap/defaults/main.yml
Normal 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
|
0
roles/global/server_bootstrap/files/.gitkeep
Normal file
0
roles/global/server_bootstrap/files/.gitkeep
Normal file
5
roles/global/server_bootstrap/handlers/main.yml
Normal file
5
roles/global/server_bootstrap/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Restart logrotate
|
||||
ansible.builtin.service:
|
||||
name: logrotate
|
||||
state: restarted
|
18
roles/global/server_bootstrap/meta/main.yml
Normal file
18
roles/global/server_bootstrap/meta/main.yml
Normal 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: []
|
19
roles/global/server_bootstrap/tasks/main.yml
Normal file
19
roles/global/server_bootstrap/tasks/main.yml
Normal 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
|
40
roles/global/server_bootstrap/templates/logrotate.conf.j2
Normal file
40
roles/global/server_bootstrap/templates/logrotate.conf.j2
Normal 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
|
0
roles/global/server_bootstrap/vars/main.yml
Normal file
0
roles/global/server_bootstrap/vars/main.yml
Normal file
Loading…
Add table
Reference in a new issue