Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<%- if @comment -%>
### <%= @comment %>
<%- end -%>
<%= @type %> <% if @label %><%= @label %><% end %> {
<%- @config.sort.reverse.each do |key,value| -%>
<%- if value.class == Array -%>
<%- value.each do |element| -%>
<%= key %>(<%= element %>);
<%- end -%>
<%- else -%>
<%= key %>(<%= value %>);
<%- end -%>
<%- end -%>
};
# Definition: syslog_ng::writer
#
# Description:
# Generic file-writer library for syslog-ng. Used by other
# classes to write out config files based on structured data.
#
# Parameters
# $ensure - Ensure the entry exists or not
# $type - Define the type of config block in syslog-ng (e.g.: source, filter, destination, log)
# $config - [Hash] Structured data for config. Takes Key/Value pairs, with Arrays and Strings
# accepted as a value
# $order - Ordering used within `concat`
# $comment - Extra comment added to each config
define syslog_ng::writer(
$ensure = present,
$type = undef,
$config = undef,
$order = '30',
$comment = $name,
) {
include stdlib
validate_string($type, $order)
validate_hash($config)
$label = $type ? {
/template/ => "t_${name}",
/source/ => "s_${name}",
/filter/ => "f_${name}",
/destination/ => "d_${name}",
default => undef,
}
concat::fragment { $name:
ensure => $ensure,
target => '/etc/syslog-ng/syslog-ng.conf',
order => $order,
content => template('syslog_ng/etc/syslog-ng/syslog-ng.conf.erb'),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.