Skip to content

Commit

Permalink
Merge pull request #9 from jpappa200/joes-ansible.refactor
Browse files Browse the repository at this point in the history
Joes ansible.refactor update for logging and cronjob to clean old log files.
  • Loading branch information
jhg03a committed Feb 14, 2020
2 parents 4b0ebb4 + fe80f2d commit f2bd450
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
13 changes: 10 additions & 3 deletions infrastructure/ansible/roles/traffic-router/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ tr_cache_config_json_refresh_period: 60000
# log4j.properties
tr_log4j_opts:
- "# ACCESS is set to be a Syslog Appender"
- log4j.appender.ACCESS=org.apache.log4j.RollingFileAppender
- log4j.appender.ACCESS=org.apache.log4j.DailyRollingFileAppender
- "log4j.appender.ACCESS.File={{tr_log_dir}}/access.log"
- log4j.appender.ACCESS.MaxFileSize=200MB
- log4j.appender.ACCESS.MaxBackupIndex=10
- log4j.appender.ACCESS.DatePattern='.'yyyy-MM-dd-HH
-
- "# ACCESS uses PatternLayout."
- log4j.appender.ACCESS.layout=org.apache.log4j.PatternLayout
Expand Down Expand Up @@ -171,3 +170,11 @@ tr_logging_opts:
- 1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
- 1catalina.org.apache.juli.AsyncFileHandler.rotatable = true
- 1catalina.org.apache.juli.AsyncFileHandler.maxDays = 30

# TR cronjobs to deploy
tr_crontab:
# Cleanup log files more than 2 days old.
access_cleanup:
schedule: '10 */4 * * *'
user: root
job: "/bin/find {{tr_log_dir}}/access.log.* -mmin +$((60*48)) -exec rm -f {} \; > /dev/null 2>&1"
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
- traffic_ops.properties
- server.xml

- name: Deploy Access Cleanup Crontab
template:
src: crontab.j2
dest: /etc/cron.d/access_cleanup
owner: root
group: root
mode: u+rw

- name: Copy traffic router systemd unit file
template:
src: traffic_router.service.j2
Expand Down
23 changes: 23 additions & 0 deletions infrastructure/ansible/roles/traffic-router/templates/crontab.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#}
# File deployed via ansible push

PATH=/sbin:/bin:/usr/sbin:/usr/bin
SHELL=/bin/bash
MAILTO='root'
HOME=/

{% for key, value in tr_crontab.items() %}
{{ value.schedule }} {{ value.user }} {{ value.job }}
{% endfor %}

0 comments on commit f2bd450

Please sign in to comment.