I am having trouble finding a solution in Puppet documents. I am trying to define a variable in Puppet template. For example:
If class graylog2
and apache
are defined in node class section then the template puts these variables in the config file:
# Apache logging
local5.* @<%= @server_gl -%>:<%= @service_port_gl -%> <- This part has to inserted if defined graylog2 class and apache class in node file
local5.info ~
local5.err ~
# Nginx logging
local4.* @<%= @server_gl -%>:<%= @service_port_gl -%> <- This part has to be inserted if defined graylog2 class and apache class in node file
local4.info ~
local4.err ~
Example:
if defined (Class['apache', 'graylog2'])
# Nginx logging
local4.* @<%= @server_gl -%>:<%= @service_port_gl -%>
local4.info ~
local4.err
else
# Nginx logging
local4.info ~
local4.err
I am not 100% sure, but I guess the example version would not work.
Also how could I get @server_gl
from graylog2 module
so it does not have to be defined in syslog module
.
Solution: