Created
August 22, 2013 18:27
-
-
Save jfryman/6310957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%- 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 -%> | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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