Ask Your Question
0

Template variable from common.yaml

asked 2014-10-02 06:21:55 -0500

mYzk gravatar image

Hello!

I am trying to make rsyslog take a variable from common.yaml if it exists, if it does not then it puts the default value I have defined. Example:

Nginx logging
if defined (Class[ 'apache' ]) } <- If node has apache defined for install
local4.* @<%= @variable_will_be_taken_from_common.yaml -%>:<%= @service_port -%>
local4.info ~
local4.err ~
<% else %>
local4.info ~
local4.err ~
<% end %>

How could I make this happen. I am trying to send apache/nginx logs to multiple servers on rsyslog, but if apache/nginx are not defined in node file then it puts the default value, but when it is defined then it puts the local4.* @<%= @variable_will_be_taken_from_common.yaml -%>:<%= @service_port -%> to the config and takes the @variable_will_be_taken_from_common.yaml common.yaml file.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-10-02 08:42:17 -0500

mYzk gravatar image

Solution:

# Apache logging
<% if classes.include?("httpd") %>
local5.* @<%= scope.function_hiera(["ls_gelf_host"]) %>:<%= @service_port -%> 
local5.info ~
local5.err ~
<% else %>
local5.info ~
local5.err ~
<% end %>

# Nginx logging
<% if classes.include?("nginx") %>
local4.* @<%= scope.function_hiera(["ls_gelf_host"]) %>:<%= @service_port -%> 
local4.info ~
local4.err ~
<% else %>
local4.info ~
local4.err ~
<% end %>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-02 06:20:11 -0500

Seen: 285 times

Last updated: Oct 02 '14