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

Add templates #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,17 @@ rsyslog_omit_local_logging: true

# Allow using the traditional file format.
rsyslog_traditional_file_format: true

# Templates, only for advance
rsyslog_templates: []
# - params:
# name: "<name>"
# # Allow values: list, subtree, string, plugin
# type: "list"
# string: ""
# plugin: ""
# # List of string
# descriptions: []
# # Example
# - "constant(value=\"Syslog MSG is: '\")"
# - "property(name=\"msg\")"
13 changes: 12 additions & 1 deletion tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
that:
- item is defined
- item is string
- item in [ "imuxsock", "imjournal", "imklog", "immark", "imfile" ]
- item in [ "imuxsock", "imjournal", "imklog", "immark", "imfile", "omfwd" ]
quiet: true
loop: "{{ rsyslog_mods }}"

Expand Down Expand Up @@ -117,3 +117,14 @@
- rsyslog_traditional_file_format is defined
- rsyslog_traditional_file_format is boolean
quiet: true

- name: assert | Test rsyslog_templates.params.type
ansible.builtin.assert:
that:
- item.params.type is defined
- item.params.type is string
- item.params.type in [ "list", "subtree", "string", "plugin" ]
quiet: true
loop: "{{ rsyslog_templates }}"
when:
- rsyslog_templates
23 changes: 23 additions & 0 deletions templates/advanced_rsyslog.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ include(file="/etc/rsyslog.d/*.conf" mode="optional")
{% endfor %}
{% endif %}

{% if rsyslog_templates %}
###################
#### TEMPLETES ####
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEMPLETES > TEMPLATES

###################
{% for item in rsyslog_templates %}
template(
name="{{ item.params.name }}"
type="{{ item.params.type }}"
{% if item.params.type == "string" %}
string="{{ item.params.string }}"
{% endif %}
{% if item.params.type == "plugin" %}
plugin="{{ item.params.plugin }}"
{% endif %}
){% if item.params.type == "list" %} {
{% for item2 in item.descriptions %}
{{item2}}
{% endfor %}
}
{% endif %}
{% endfor %}
{% endif %}

{% if rsyslog_remote is defined %}
#########################
#### FORWARDING RULE ####
Expand Down