From 65d8984dad9fe98fcc18bd0058e37cf12359483c Mon Sep 17 00:00:00 2001
From: CVL-GitHub <jupiter.hu@monash.edu>
Date: Wed, 23 Sep 2015 15:14:19 +1000
Subject: [PATCH] fixed slurm log rotate config for centos 7

---
 .../tasks/installSlurmFromSource.yml          |  6 +++++
 roles/slurm-common/templates/slurmdblog.j2    | 24 +++++++++++++++++++
 roles/slurm-common/templates/slurmlog.j2      | 19 +++++++--------
 3 files changed, 39 insertions(+), 10 deletions(-)
 create mode 100644 roles/slurm-common/templates/slurmdblog.j2

diff --git a/roles/slurm-common/tasks/installSlurmFromSource.yml b/roles/slurm-common/tasks/installSlurmFromSource.yml
index 3a3d2f2a..641e03ef 100644
--- a/roles/slurm-common/tasks/installSlurmFromSource.yml
+++ b/roles/slurm-common/tasks/installSlurmFromSource.yml
@@ -37,3 +37,9 @@
   template: src=slurmlog.j2 dest=/etc/logrotate.d/slurm mode=644
   sudo: true
 
+- name: add slurm db log rotate config
+  template: src=slurmdblog.j2 dest=/etc/logrotate.d/slurmdb mode=644
+  sudo: true
+  delegate_to: "{{ slurmctrl }}"
+
+
diff --git a/roles/slurm-common/templates/slurmdblog.j2 b/roles/slurm-common/templates/slurmdblog.j2
new file mode 100644
index 00000000..f9042d6b
--- /dev/null
+++ b/roles/slurm-common/templates/slurmdblog.j2
@@ -0,0 +1,24 @@
+{{ slurmdbdlog.log }}
+{% endif %}
+{
+ compress
+ missingok 
+ nocopytruncate 
+ nocreate 
+ nodelaycompress 
+ nomail  
+ notifempty 
+ noolddir 
+ rotate 5 
+ sharedscripts 
+ size=5M 
+ create 640 slurm root 
+{% if ansible_os_family == 'RedHat' and ansible_distribution_version >= '7' %}
+  postrotate
+    {{ slurm_dir }}/sbin/slurmdbd flushlogs  1>/dev/null || true
+{% else %}
+ postrotate /etc/init.d/slurmdbd reconfig 
+{% endif %}
+ endscript
+}
+
diff --git a/roles/slurm-common/templates/slurmlog.j2 b/roles/slurm-common/templates/slurmlog.j2
index 54731e01..b78e6db4 100644
--- a/roles/slurm-common/templates/slurmlog.j2
+++ b/roles/slurm-common/templates/slurmlog.j2
@@ -1,4 +1,9 @@
-{{ slurmddebug.log }}/slurm*.log
+{% if slurmctrl == inventory_hostname %}
+{{ slurmctlddebug.log }}
+{{ slurmschedlog.log }}
+{% else *}
+{{ slurmddebug.log }}
+{% endif %}
 {
  compress
  missingok 
@@ -12,18 +17,12 @@
  sharedscripts 
  size=5M 
  create 640 slurm root 
-{% if slurmctrl == inventory_hostname %}
-{% if ansible_os_family == 'RedHat' and ansible_distribution_version >= '7' %}
-  systemctl restart slurmdbd
-{% else %}
- postrotate /etc/init.d/slurmdbd reconfig 
-{% endif %}
-{% endif %}
 {% if ansible_os_family == 'RedHat' and ansible_distribution_version >= '7' %}
+ postrotate
 {% if slurmctrl == inventory_hostname %}
-  systemctl restart slurmctld 
+   {{ slurm_dir }}/sbin/slurmctld flushlogs 1>/dev/null || true
 {% else %}
-  systemctl restart slurmd 
+   {{ slurm_dir }}/sbin/slurmd flushlogs 1>/dev/null || true
 {% endif %}
 {% else %}
  postrotate /etc/init.d/slurm reconfig 
-- 
GitLab