Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to create a puppet recipe for a log server and client using syslog-ng. I know I can have custom configuration files using template erb files and replace certain variables in the erb files. I know also that the file resource just replaces the files either from source or template.

However, my problem is that every client will have different requirements and a different number of files to be redirected and most clients do not use syslog APIs to log their information so I have to specify the file names for each application on every client and accordingly have to keep adding stuff to the server conf file too.

I could not find any kind of loop functionality in puppet that could help me to generate or add information into an existing syslog-ng.conf file. All I see is that the file resource will replace the existing one, unless I do something smart using exec.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You could try creating a template with some variables like

source s_<%= localhost_name%> {
tcp(ip(0.0.0.0)
port(<%= log_port%>));
};

template t_<%= localhost_name%> {
template ("$MSGHDR$MSG\n");
template_escape(no);
};

destination d_<%= localhost_name%>  {
file("<%= log_file%>" template(t_<%= localhost_name%>));
};

log {
source(s_<%= localhost_name%>);
destination(d_<%= localhost_name%>);
};

This will generate a file that will listen to all TCP address at syslog port and filter the messages accordingly.

share|improve this answer

In that case you should look closely at the configuration file in question and see if it supports some kind of include directory. That is you can put configuration files into a sub-directory and instruct the main program to include it. That way each subsystem can simply add the configuration fragments as required. Syslog-ng does appear to support this type of setup.

If that is not built-in to the application in question, then you can use the concatenate pattern where you basically have puppet assemble the configuration on the client side from a bunch of configuration fragments.

share|improve this answer
    
Thanks I think both will work perfect. –  chandank Oct 22 '12 at 17:23
    
@chandank The information in the wiki page linked in Zordache's answer is quite out of date. The "canonical" way of doing concatenation of file fragments is with R.I. Pienaar's concat module: github.com/ripienaar/puppet-concat –  daff Oct 22 '12 at 19:25
    
@daff, not that it maters in the case of syslog-ng since it natively has an include feature, so concat is probably not needed, but can you provide a citation for that statement? I'll accept that Pienaar's may be a better module, but I wonder where you found that documented? –  Zoredache Oct 22 '12 at 19:39
2  
@Zoredache, I have no citations other than what I hear on IRC, plus it seems to me everything made by Pienaar is better than its alternatives :) Just wanted to make sure that the concat module is mentioned in this discussion about the concatenation pattern, since it is not documented in the wiki page. Also, the page itself hasn't been updated in over a year and a half, which isn't surprising given the fact that most of content in the Puppet wiki is considered obsolete. –  daff Oct 22 '12 at 20:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.