Skip to content

Commit dd60029

Browse files
author
Christopher M. Neill
committed
any service that will use rsyslog will need to reference the role in their main playbook (or down the road we just automatically include it via some ansible sorcery).
shipped.
1 parent 3d9ad6f commit dd60029

5 files changed

Lines changed: 19 additions & 9 deletions

File tree

ansible/krain.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
- { role: notify, tags: [notify] }
99
- { role: build_essential }
1010
- { role: git_node_service, tags: [deploy] }
11+
- { role: loggly }
1112
- { role: consul_value, tags: [deploy, consul_value] }

ansible/roles/builder/templates/basic_node/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ RUN {{ command }}
3434
{% endif %}
3535

3636
# Define default command.
37-
CMD ulimit -c unlimited && /usr/local/bin/npm {{ npm_start_command | default('start') }} > /var/log/{{ name }}.log 2>&1
37+
CMD ulimit -c unlimited && /usr/local/bin/npm {{ npm_start_command | default('start') }} >> /var/log/{{ name }}-npm.log 2>&1
3838

ansible/roles/loggly/tasks/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@
7676
path=/var/log/{{ name }}.log
7777
state=absent
7878

79+
- name: touch the log file
80+
tags: [loggly, deploy]
81+
sudo: yes
82+
file:
83+
path=/var/log/{{ name }}.log
84+
state=touch
85+
owner=syslog
86+
group=adm
87+
7988
- name: restart rsyslog
8089
tags: [loggly, deploy]
8190
sudo: yes

ansible/roles/loggly/templates/21-output-syslog.conf.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ $PrivDropToGroup adm
33

44
# start log rotation via outchannel
55
# outchannel definition
6-
$outchannel log_rotation_{{ name }},/var/log/{{ name }}.log, 52428800,/opt/runnable/bin/rotate-{{ name }}-logs.sh
6+
$outchannel log_rotation_{{ name }},/var/log/{{ name }}.log,52428800,/opt/runnable/bin/rotate-{{ name }}-logs.sh
77
# activate the channel and log everything to it
8-
local7.* :omfile:$log_rotation_{{ name }}
8+
if $msg contains '{{ name }}' and $syslogfacility-text == 'local7' then :omfile:$log_rotation_{{ name }}
99
# end log rotation via outchannel
1010

1111
# {{ name }} access file:
1212
#Add a tag for {{ name }} events
1313
$template LogglyFormatFile{{ name }},"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [f673760d-e0b3-4a93-a15e-2862ea074f91@41058 tag=\"file\" ] %msg%\n"
14-
if $programname == '{{ name }}' then @@logs-01.loggly.com:514;LogglyFormatFile{{ name }}
15-
if $programname == '{{ name }}' then ~
14+
if $msg contains '{{ name }}' then @@logs-01.loggly.com:514;LogglyFormatFile{{ name }}
15+
if $msg contains '{{ name }}' then ~

ansible/roles/loggly/templates/rsyslog.conf.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ $ModLoad imklog # provides kernel logging support
1515
#$ModLoad immark # provides --MARK-- message capability
1616

1717
# provides UDP syslog reception
18-
#$ModLoad imudp
19-
#$UDPServerRun 514
18+
$ModLoad imudp
19+
$UDPServerRun 514
2020

2121
# provides TCP syslog reception
22-
#$ModLoad imtcp
23-
#$InputTCPServerRun 514
22+
$ModLoad imtcp
23+
$InputTCPServerRun 514
2424

2525
# Enable non-kernel facility klog messages
2626
$KLogPermitNonKernelFacility on

0 commit comments

Comments
 (0)