Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint #48

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Lint #48

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/
---
- name: Converge
hosts: all
become: yes
gather_facts: yes
become: true
gather_facts: true

roles:
- role: robertdebock.rsyslog
Expand All @@ -27,8 +27,8 @@ The machine needs to be prepared. In CI this is done using [`molecule/default/pr
---
- name: Prepare
hosts: all
become: yes
gather_facts: no
become: true
gather_facts: false

roles:
- role: robertdebock.bootstrap
Expand All @@ -44,38 +44,44 @@ The default values for the variables are set in [`defaults/main.yml`](https://gi
---
# defaults file for rsyslog

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

# To forward logs to another server, set rsyslog_remote to the hostname or
# the ipaddress of the receiving rsyslog server.
# Not setting this variable will not forward logs.
# rsyslog_remote: server1.example.com

# If rsylog_remote is set, sets the "selector" pattern for determining which
# If rsyslog_remote is set, sets the "selector" pattern for determining which
# messages to send to the remote server. Default "*.*" sends everything.
# See `man rsyslog.conf`.
rsyslog_remote_selector: "*.*"

# If rsylog_remote is set, use TCP if yes. UDP if no.
rsyslog_remote_tcp: yes
# If rsyslog_remote is set, use TCP if true. UDP if false.
rsyslog_remote_tcp: true

# If rsylog_remote is set, destination port to use.
# If rsyslog_remote is set, destination port to use.
rsyslog_remote_port: 514

# Set the mode for new directories; only available in legacy template.
# rsyslog_fileowner: syslog

# rsyslog_filegroup: adm

# Set the mode for new directories.
rsyslog_dircreatemode: "0700"

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

# rsyslog_umask: "0022"

# Set the mods enabled
rsyslog_mods:
- imuxsock
- imjournal

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

# Default rsyslogd rules
rsyslog_default_rules:
Expand Down Expand Up @@ -105,7 +111,7 @@ 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: no
rsyslog_preservefqdn: false

# Configure additional config files in /etc/rsyslog.d
# Example:
Expand All @@ -120,10 +126,10 @@ rsyslog_rsyslog_d_files: []

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

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

# Install additional rsyslog packages
# Example for installing rsyslog-elastisearch:
Expand All @@ -136,10 +142,10 @@ rsyslog_features: []
rsyslog_dest_conf_file: "/etc/rsyslog.conf"

# Enable / Disable option OmitLocalLogging
rsyslog_omit_local_logging: yes
rsyslog_omit_local_logging: true

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

## [Requirements](#requirements)
Expand Down
36 changes: 21 additions & 15 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
---
# defaults file for rsyslog

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

# To forward logs to another server, set rsyslog_remote to the hostname or
# the ipaddress of the receiving rsyslog server.
# Not setting this variable will not forward logs.
# rsyslog_remote: server1.example.com

# If rsylog_remote is set, sets the "selector" pattern for determining which
# If rsyslog_remote is set, sets the "selector" pattern for determining which
# messages to send to the remote server. Default "*.*" sends everything.
# See `man rsyslog.conf`.
rsyslog_remote_selector: "*.*"

# If rsylog_remote is set, use TCP if yes. UDP if no.
rsyslog_remote_tcp: yes
# If rsyslog_remote is set, use TCP if true. UDP if false.
rsyslog_remote_tcp: true

# If rsylog_remote is set, destination port to use.
# If rsyslog_remote is set, destination port to use.
rsyslog_remote_port: 514

# Set the mode for new directories; only available in legacy template.
# rsyslog_fileowner: syslog

# rsyslog_filegroup: adm

# Set the mode for new directories.
rsyslog_dircreatemode: "0700"

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

# rsyslog_umask: "0022"

# Set the mods enabled
rsyslog_mods:
- imuxsock
- imjournal

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

# Default rsyslogd rules
rsyslog_default_rules:
Expand Down Expand Up @@ -62,7 +68,7 @@ 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: no
rsyslog_preservefqdn: false

# Configure additional config files in /etc/rsyslog.d
# Example:
Expand All @@ -77,10 +83,10 @@ rsyslog_rsyslog_d_files: []

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

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

# Install additional rsyslog packages
# Example for installing rsyslog-elastisearch:
Expand All @@ -93,7 +99,7 @@ rsyslog_features: []
rsyslog_dest_conf_file: "/etc/rsyslog.conf"

# Enable / Disable option OmitLocalLogging
rsyslog_omit_local_logging: yes
rsyslog_omit_local_logging: true

# Allow using the traditional file format.
rsyslog_traditional_file_format: yes
rsyslog_traditional_file_format: true
4 changes: 2 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- name: Converge
hosts: all
become: yes
gather_facts: yes
become: true
gather_facts: true

roles:
- role: ansible-role-rsyslog
4 changes: 2 additions & 2 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ platforms:
command: /sbin/init
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: yes
pre_build_image: yes
privileged: true
pre_build_image: true
provisioner:
name: ansible
verifier:
Expand Down
4 changes: 2 additions & 2 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- name: Prepare
hosts: all
become: yes
gather_facts: no
become: true
gather_facts: false

roles:
- role: robertdebock.bootstrap
4 changes: 2 additions & 2 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- name: Verify
hosts: all
become: yes
gather_facts: no
become: true
gather_facts: false

tasks:
- name: Check if connection still works
Expand Down
32 changes: 16 additions & 16 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
that:
- rsyslog_receiver is defined
- rsyslog_receiver is boolean
quiet: yes
quiet: true

- name: assert | Test rsyslog_preservefqdn
ansible.builtin.assert:
that:
- rsyslog_preservefqdn is defined
- rsyslog_preservefqdn is boolean
quiet: yes
quiet: true

- name: assert | Test rsyslog_remote_selector
ansible.builtin.assert:
that:
- rsyslog_remote_selector is defined
- rsyslog_remote_selector is string
- rsyslog_remote_selector is not none
quiet: yes
quiet: true

- name: assert | Test rsyslog_remote_port
ansible.builtin.assert:
Expand All @@ -29,78 +29,78 @@
- rsyslog_remote_port is number
- rsyslog_remote_port > 0
- rsyslog_remote_port < 65536
quiet: yes
quiet: true

- name: assert | Test rsyslog_dircreatemode
ansible.builtin.assert:
that:
- rsyslog_dircreatemode is defined
- rsyslog_dircreatemode is string
- rsyslog_dircreatemode is not none
quiet: yes
quiet: true

- name: assert | Test rsyslog_filecreatemode
ansible.builtin.assert:
that:
- rsyslog_filecreatemode is defined
- rsyslog_filecreatemode is string
- rsyslog_filecreatemode is not none
quiet: yes
quiet: true

- name: assert | Test rsyslog_mods
ansible.builtin.assert:
that:
- rsyslog_mods is defined
- rsyslog_mods is iterable
quiet: yes
quiet: true

- name: assert | Test item in rsyslog_mods
ansible.builtin.assert:
that:
- item is defined
- item is string
- item in [ "imuxsock", "imjournal", "imklog", "immark", "imfile" ]
quiet: yes
quiet: true
loop: "{{ rsyslog_mods }}"

- name: assert | Test rsyslog_deploy_default_config
ansible.builtin.assert:
that:
- rsyslog_deploy_default_config is defined
- rsyslog_deploy_default_config is boolean
quiet: yes
quiet: true

- name: assert | Test rsyslog_forward_rule_name
ansible.builtin.assert:
that:
- rsyslog_forward_rule_name is defined
- rsyslog_forward_rule_name is string
- rsyslog_forward_rule_name is not none
quiet: yes
quiet: true
when:
- rsyslog_deploy_default_config == "no"
- not rsyslog_deploy_default_config

- name: assert | Test rsyslog_config_file_format
ansible.builtin.assert:
that:
- rsyslog_config_file_format is defined
- rsyslog_config_file_format is string
- rsyslog_config_file_format in [ "legacy", "advanced" ]
quiet: yes
quiet: true

- name: assert | Test rsyslog_package_state
ansible.builtin.assert:
that:
- rsyslog_package_state is defined
- rsyslog_package_state is string
- rsyslog_package_state in [ "present", "latest" ]
quiet: yes
quiet: true

- name: assert | Test rsyslog_features
ansible.builtin.assert:
that:
- rsyslog_features is iterable
quiet: yes
quiet: true
when:
- rsyslog_features is defined

Expand All @@ -109,11 +109,11 @@
that:
- rsyslog_omit_local_logging is defined
- rsyslog_omit_local_logging is boolean
quiet: yes
quiet: true

- name: assert | Test rsyslog_traditional_file_format
ansible.builtin.assert:
that:
- rsyslog_traditional_file_format is defined
- rsyslog_traditional_file_format is boolean
quiet: yes
quiet: true
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- name: Import assert.yml
ansible.builtin.import_tasks:
file: assert.yml
run_once: yes
run_once: true
delegate_to: localhost

- name: Uninstall conflicting systemd-logger
Expand Down Expand Up @@ -67,4 +67,4 @@
ansible.builtin.service:
name: "{{ rsyslog_service }}"
state: started
enabled: yes
enabled: true
Loading