An open API service indexing awesome lists of open source software.

https://github.com/robertdebock/ansible-role-rsyslog

Install and configure rsyslog on your system.
https://github.com/robertdebock/ansible-role-rsyslog

ansible installer molecule monitoring package playbook rsyslog tox

Last synced: 4 months ago
JSON representation

Install and configure rsyslog on your system.

Awesome Lists containing this project

README

          

# [Ansible role rsyslog](#ansible-role-rsyslog)

Install and configure rsyslog on your system.

|GitHub|GitLab|Downloads|Version|
|------|------|---------|-------|
|[![github](https://github.com/robertdebock/ansible-role-rsyslog/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-rsyslog/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-rsyslog/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-rsyslog)|[![downloads](https://img.shields.io/ansible/role/d/robertdebock/rsyslog)](https://galaxy.ansible.com/robertdebock/rsyslog)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-rsyslog.svg)](https://github.com/robertdebock/ansible-role-rsyslog/releases/)|

## [Example Playbook](#example-playbook)

This example is taken from [`molecule/default/converge.yml`](https://github.com/robertdebock/ansible-role-rsyslog/blob/master/molecule/default/converge.yml) and is tested on each push, pull request and release.

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

roles:
- role: robertdebock.rsyslog
rsyslog_mods:
- imuxsock
```

The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/robertdebock/ansible-role-rsyslog/blob/master/molecule/default/prepare.yml):

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

roles:
- role: robertdebock.bootstrap

# In CI, rsyslog does not send sd_notify(READY=1) in time.
# Override to Type=simple so systemd considers the service started
# when the process is up and does not wait for READY.
tasks:
- name: Create systemd drop-in directory for rsyslog.service
ansible.builtin.file:
path: /etc/systemd/system/rsyslog.service.d
state: directory
mode: "0755"

- name: Set rsyslog.service Type=simple so systemd does not wait for READY
ansible.builtin.copy:
dest: /etc/systemd/system/rsyslog.service.d/type-simple.conf
content: |
[Service]
Type=simple
mode: "0644"

- name: Reload systemd after rsyslog drop-in
ansible.builtin.systemd:
daemon_reload: true
```

Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles.

## [Role Variables](#role-variables)

The default values for the variables are set in [`defaults/main.yml`](https://github.com/robertdebock/ansible-role-rsyslog/blob/master/defaults/main.yml):

```yaml
---
# defaults file for rsyslog

# To configure a server to receive logs, set rsyslog_receiver to yes.
rsyslog_receiver: false

# To forward logs to a remote server, add items to the rsyslog_remotes list.
# Each item should be a map like the following:
rsyslog_remotes:
- selector: '*.*'
hostname: logging.server.net
port: 514 # (optional, default 514)
tcp: true # (optional, default true)
# extra_params: 'KeepAlive="on"'

# If rsyslog_remotes is set, optional template name for the forward action.
# Leave empty or unset to use the default format.
rsyslog_remote_template: ""

# Additional parameters to pass to the omfwd action in advanced
# configuration mode. This value is appended as-is to the action()
# definition, so it should contain valid omfwd options, for example:
# StreamDriver="gtls" StreamDriverMode="1" StreamDriverAuthMode="x509/certvalid"
# Leave empty to not add any extra parameters.
rsyslog_remote_extra_params: ""

# Set the mode for new directories; only available in legacy template.
rsyslog_dircreatemode: "0700"

# Set the mode for new files; only available in legacy template.
rsyslog_filecreatemode: "0644"

# Security: owner and group for rsyslog config files and directory (CIS recommends root).
rsyslog_config_owner: root
rsyslog_config_group: root

# Security: mode for rsyslog config files (CIS recommends 0600).
rsyslog_config_mode: "0600"

# Security: mode for rsyslog config directory /etc/rsyslog.d/.
rsyslog_config_dir_mode: "0755"

# Set the mods enabled. An empty list is valid for receiver-only setups where no
# input modules (imuxsock, imjournal, imklog, immark, imfile) are needed.
rsyslog_mods:
- imuxsock
- imjournal

# Configure rsyslog minimally (may be in conflict with custom configuration files)
rsyslog_deploy_default_config: true

# Default rsyslogd rules
rsyslog_default_rules:
- { rule: '*.info;mail.none;authpriv.none;cron.none', logpath: '/var/log/messages' }
- { rule: 'authpriv.*', logpath: '/var/log/secure' }
- { rule: 'mail.*', logpath: '-/var/log/maillog' }
- { rule: 'cron.*', logpath: '/var/log/cron' }
- { rule: '*.emerg', logpath: ':omusrmsg:*' }
- { rule: 'uucp,news.crit', logpath: '/var/log/spooler' }
- { rule: 'local7.*', logpath: '/var/log/boot.log' }

# Use the (obsolete) legacy, pre-v6 configuration file format, or the more
# modern # 'advanced' configuration file format available in v6 and up. The
# default is to use the 'legacy' format to not change config files for
# existing users of this role out of the blue.
# More information on the different formats on the rsyslog website:
# https://www.rsyslog.com/doc/v8-stable/configuration/conf_formats.html
rsyslog_config_file_format: legacy

# The rule conf to name to add to /etc/rsyslog.d/ when rsyslog_remote is set.
rsyslog_forward_rule_name: forwarding

# Configure the rsyslog package to be `present`, or set to `latest` to install
# the latest available version.
rsyslog_package_state: present

# if set to false (legacy default to remain compatible to sysklogd), the domain
# part from a name that is within the same domain as the receiving system is
# stripped. If set to on, full names are always used.
rsyslog_preservefqdn: false

# Configure additional config files in /etc/rsyslog.d
# Example:
# rsyslog_rsyslog_d_files:
# - name: 000-splunk
# state: present
# validate: true
# content: |
# auth,authpriv.* action(type="omfwd"
# target="splunk"
# port="514"
# protocol="tcp")
rsyslog_rsyslog_d_files: []

# Avoid sd_journal_get_cursor() failed: Cannot assign requested address messages
# due to logrotate
rsyslog_workaroundjournalbug: false

# Turns off message reception via local log socket
rsyslog_imuxsock_syssock: false

# Install additional rsyslog packages
# Example for installing rsyslog-elastisearch:
# rsyslog_features:
# - gnutls
# - elastisearch
rsyslog_features: []

# Default destination of rsyslog config file
rsyslog_dest_conf_file: "/etc/rsyslog.conf"

# Enable / Disable option OmitLocalLogging
rsyslog_omit_local_logging: true

# Allow using the traditional file format.
rsyslog_traditional_file_format: true
```

## [Requirements](#requirements)

- pip packages listed in [requirements.txt](https://github.com/robertdebock/ansible-role-rsyslog/blob/master/requirements.txt).

## [State of used roles](#state-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](https://galaxy.ansible.com/robertdebock/bootstrap)|[![Build Status GitHub](https://github.com/robertdebock/ansible-role-bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bootstrap/actions)|[![Build Status GitLab](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap)|

## [Context](#context)

This role is part of many compatible roles. Have a look at [the documentation of these roles](https://robertdebock.nl/) for further information.

Here is an overview of related roles:
![dependencies](https://raw.githubusercontent.com/robertdebock/ansible-role-rsyslog/png/requirements.png "Dependencies")

## [Compatibility](#compatibility)

This role has been tested on these [container images](https://hub.docker.com/u/robertdebock):

|container|tags|
|---------|----|
|[EL](https://hub.docker.com/r/robertdebock/enterpriselinux)|9|
|[Debian](https://hub.docker.com/r/robertdebock/debian)|all|
|[Fedora](https://hub.docker.com/r/robertdebock/fedora)|all|
|[Ubuntu](https://hub.docker.com/r/robertdebock/ubuntu)|all|

The minimum version of Ansible required is 2.12, tests have been done on:

- The previous version.
- The current version.
- The development version.

If you find issues, please register them on [GitHub](https://github.com/robertdebock/ansible-role-rsyslog/issues).

## [License](#license)

[Apache-2.0](https://github.com/robertdebock/ansible-role-rsyslog/blob/master/LICENSE).

## [Author Information](#author-information)

[robertdebock](https://robertdebock.nl/)

Please consider [sponsoring me](https://github.com/sponsors/robertdebock).