Skip to content

Commit

Permalink
Version 1.6.0
Browse files Browse the repository at this point in the history
Release 1.6.0
  • Loading branch information
sbaerlocher authored Oct 3, 2020
2 parents 038649f + 358dbdf commit 4142cde
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 71 deletions.
15 changes: 3 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,15 @@ language: python
services: docker

env:
global:
- ROLE_NAME: logrotate
matrix:
- MOLECULE_DISTRO: centos8
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: centos6
- MOLECULE_DISTRO: ubuntu2004
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: debian9
- MOLECULE_DISTRO: debian10

install:
- pip install molecule docker

- git clone https://github.com/arillso/tests molecule/default/lint

before_script:
- cd ../
- mv ansible.$ROLE_NAME arillso.$ROLE_NAME
- cd arillso.$ROLE_NAME
- pip install molecule yamllint ansible-lint docker

script:
- molecule test
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
and [human-readable changelog](https://keepachangelog.com/en/1.0.0/).

## 1.6.0

### Fixed

- Travis CI and molecule setup.
- The src option requires state to be 'link' or 'hard' (breaking in Ansible
2.10) (Fixes: #14).

### Changed

- `logrotate_use_hourly_rotation` will no longer clean the symlink in
`cron.daily`.
- Bumped tested distros versions.

### Added

- Options to enable or not wtmp/btmp config by [smutel](https://github.com/smutel)
via PR #25 (Fixes: #23).
- Option to skip global configuration file by [fhsctv](https://github.com/fhsctv)
via PR #28.

## 1.5.2

### Fixed
Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description

Installs and configures logrotate
Installs and configures logrotate.

## Installation

Expand All @@ -14,21 +14,29 @@ Installs and configures logrotate

## Requirements

None
None.

## Role Variables

### imclude files
### include files

Path to the imclude files.

```yml
logrotate_include_dir: /etc/logrotate.d
```
### logrotate_global_config
Enable/disable global configuration of `/etc/logrotate.conf`.

```yml
logrotate_global_config: true
```

### logrotate_use_hourly_rotation

Enable hourly rotation with cron.
Enable/disable hourly rotation with cron.

```yml
logrotate_use_hourly_rotation: false
Expand All @@ -49,17 +57,18 @@ logrotate_options:

### Package

package name to install logrotate.
Package name to install `logrotate`.

```yml
logrotate_package: logrotate
```

### default config

logroate for wtmp
Logrotate for `wtmp`:

```yml
logrotate_wtmp_enable: true
logrotate_wtmp:
logs:
- /var/log/wtmp
Expand All @@ -70,9 +79,10 @@ logrotate_wtmp:
- rotate 1
```

logroate for btmp
Logrotate for `btmp`:

```yml
logrotate_btmp_enable: true
logrotate_btmp:
logs:
- /var/log/btmp
Expand All @@ -83,7 +93,7 @@ logrotate_btmp:
- rotate 1
```

### applications config
### Applications config

More log files can be added that will logorate.

Expand Down
13 changes: 8 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
---
# defaults file for arillso.logrotate

# List of global options. If this is empty the default options of the
# distribution are used.
logrotate_options: []

# Path to the imclude files
logrotate_include_dir: /etc/logrotate.d

# package name to install logrotate.
# Package name to install logrotate.
logrotate_package: logrotate

# Enable global configuration handling
logrotate_global_config: true

# Enable hourly rotation with cron.
logrotate_use_hourly_rotation: false

# logroate for wtmp
# Logrotate for wtmp
logrotate_wtmp_enable: true
logrotate_wtmp:
logs:
- /var/log/wtmp
Expand All @@ -24,7 +26,8 @@ logrotate_wtmp:
- create 0664 root utmp
- rotate 1

# logroate for btmp
# Logrotate for btmp
logrotate_btmp_enable: true
logrotate_btmp:
logs:
- /var/log/btmp
Expand Down
2 changes: 0 additions & 2 deletions handlers/main.yml

This file was deleted.

12 changes: 6 additions & 6 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
dependencies: []

galaxy_info:
role_name: unbound
author: 'arillso'
description: 'Ansible role for installs and configures logratet on Linux'
license: MIT
min_ansible_version: 2.8
platforms:
- name: EL
versions:
- 6
- 7
- 8
- name: Fedora
versions:
- 29
- 32
- name: Ubuntu
versions:
- bionic
- cosmic
- disco
- focal
- name: Debian
versions:
- jessie
- stretch
- buster

galaxy_tags:
Expand Down
12 changes: 12 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Converge
hosts: all

pre_tasks:
- name: update apt cache
apt: update_cache=yes cache_valid_time=600
when: ansible_distribution == 'Ubuntu'
changed_when: false

roles:
- role: ansible.logrotate
16 changes: 6 additions & 10 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: 'geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest'
image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
lint: |
set -e
yamllint .
ansible-lint
5 changes: 0 additions & 5 deletions molecule/default/playbook.yml

This file was deleted.

19 changes: 10 additions & 9 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
# tasks file for arillso.logrotate

- name: add OS specific variables
include_vars: '{{ loop_vars }}'
with_first_found:
Expand All @@ -23,7 +21,7 @@
- configuration
- packages

- name: 'install logrotate packages'
- name: install logrotate packages
become: true
package:
name: '{{ logrotate_package }}'
Expand All @@ -34,7 +32,7 @@
tags:
- packages

- name: 'create logrotate configuration file'
- name: create logrotate configuration file
become: true
template:
src: 'etc/logrotate.conf.j2'
Expand All @@ -44,8 +42,9 @@
mode: 0644
tags:
- configuration
when: logrotate_global_config | bool

- name: 'create logrotate application configuration files'
- name: create logrotate application configuration files
become: true
template:
src: 'etc/logrotate.d/application.j2'
Expand All @@ -58,8 +57,10 @@
tags:
- configuration

- name: Symlink for hourly rotation
- name: symlink for hourly rotation
file:
path: "/etc/cron.hourly/logrotate"
src: "/etc/cron.daily/logrotate"
state: "{{ 'link' if logrotate_use_hourly_rotation else 'absent' }}"
path: '/etc/cron.hourly/logrotate'
src: '/etc/cron.daily/logrotate'
mode: 0644
state: link
when: logrotate_use_hourly_rotation | bool
4 changes: 4 additions & 0 deletions templates/etc/logrotate.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@
include {{ logrotate_include_dir }}

# no packages own wtmp, or btmp -- we'll rotate them here
{% if logrotate_wtmp_enable %}
{{ logrotate_wtmp.logs | join(" ") }} {
{% for option in logrotate_wtmp.options %}
{{ option }}
{% endfor %}
}
{% endif %}

{% if logrotate_btmp_enable %}
{{ logrotate_btmp.logs | join(" ") }} {
{% for option in logrotate_btmp.options %}
{{ option }}
{% endfor %}
}
{% endif %}

# system-specific logs may be configured here
3 changes: 0 additions & 3 deletions vars/CentOS.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
# vars file for arillso.logrotate

# List of global options for the different systems.
logrotate_distribution_options:
- weekly
- rotate 4
Expand Down
3 changes: 0 additions & 3 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
# vars file for arillso.logrotate

# List of global options for the different systems.
logrotate_distribution_options:
- weekly
- rotate 4
Expand Down
3 changes: 0 additions & 3 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
# vars file for arillso.logrotate

# List of global options for the different systems.
logrotate_distribution_options:
- weekly
- rotate 4
Expand Down
3 changes: 0 additions & 3 deletions vars/Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
# vars file for arillso.logrotate

# List of global options for the different systems.
logrotate_distribution_options:
- weekly
- rotate 4
Expand Down
2 changes: 0 additions & 2 deletions vars/defaults.yml

This file was deleted.

0 comments on commit 4142cde

Please sign in to comment.