Skip to content

Commit

Permalink
Merge pull request #22 from companieshouse/feature/tuxedo-log-rotation
Browse files Browse the repository at this point in the history
Add log rotation for Tuxedo services
  • Loading branch information
marcransome authored May 12, 2021
2 parents f15eafb + 0e0387b commit 397ec2a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions roles/deploy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cloudwatch_agent:
user: cwagent

tuxedo_logs_path: /var/log/tuxedo
tuxedo_log_rotation_config_path: /etc/logrotate.tuxedo.conf

tuxedo_log_files:
ewf:
Expand Down
17 changes: 16 additions & 1 deletion roles/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,29 @@
group: "{{ tuxedo_service_group }}"
mode: 0755

- name: "Create Tuxedo logs directory"
- name: Create Tuxedo logs directory
file:
path: "{{ tuxedo_logs_path }}"
owner: root
group: "{{ tuxedo_service_group }}"
mode: 0755
state: directory

- name: Create shared log rotation configuration for Tuxedo services
template:
src: templates/logrotate.tuxedo.conf.j2
dest: "{{ tuxedo_log_rotation_config_path }}"

- name: Create system cron job for log rotation
cron:
name: Log rotation for Tuxedo services
weekday: "*"
minute: "*/15"
hour: "*"
user: "root"
job: "logrotate {{ tuxedo_log_rotation_config_path }}"
cron_file: /etc/crontab

- include_tasks: deploy.yml
loop: "{{ tuxedo_service_users }}"
loop_control:
Expand Down
28 changes: 28 additions & 0 deletions roles/deploy/templates/logrotate.tuxedo.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{ tuxedo_logs_path }}/*/*-ngsrv.log {{ tuxedo_logs_path }}/*/*-stdout.txt {{ tuxedo_logs_path }}/*/*-stderr.txt {
daily
copytruncate
compress
maxage 7
maxsize 1G
missingok
notifempty
olddir old
rotate 20
createolddir 0755 root root
}

{{ tuxedo_logs_path }}/*/ULOG.* {
daily
copytruncate
compress
maxage 93
maxsize 1800M
missingok
notifempty
olddir old
rotate 20
createolddir 0755 root root
lastaction
/bin/find /var/log/tuxedo -maxdepth 2 -name 'ULOG.*' -mtime +1 -size 0 -delete
endscript
}

0 comments on commit 397ec2a

Please sign in to comment.