From 226b63b275d150964e12374f122ea9feba443c87 Mon Sep 17 00:00:00 2001
From: CVL-GitHub <jupiter.hu@monash.edu>
Date: Mon, 21 Sep 2015 16:04:47 +1000
Subject: [PATCH] fixed nhc mark-online script and added slurm log relotate
 script

---
 roles/karaage3.1.17/templates/kg_init.j2      |  4 +--
 .../tasks/installSlurmFromSource.yml          |  5 ++++
 roles/slurm-common/templates/nhclog.j2        |  3 +-
 roles/slurm-common/templates/slurmlog.j2      | 29 +++++++++++++++++++
 4 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 roles/slurm-common/templates/slurmlog.j2

diff --git a/roles/karaage3.1.17/templates/kg_init.j2 b/roles/karaage3.1.17/templates/kg_init.j2
index 5d4cdd3..110f3b7 100755
--- a/roles/karaage3.1.17/templates/kg_init.j2
+++ b/roles/karaage3.1.17/templates/kg_init.j2
@@ -154,7 +154,6 @@ class HpcIdInit():
             institute = Institute.objects.get(name = user["institute_name"])
             if institute:
                 person = Person.objects.create(username = user["username"], email = user["email"], password = self.password, short_name = user["short_name"], full_name = user["full_name"], is_admin = True, is_active = True, institute = institute)    
-                person.full_clean()
                 if person:
                     person.set_password(self.password)
                     person.save()
@@ -163,6 +162,7 @@ class HpcIdInit():
                         log("Add super user %s to institute %s delegate" %(person.username, institute.name))
                     else:
                         log("Faired to add super user %s to institute %s delegate" %(person.username, institute.name))
+                    person.full_clean()
         except:
             log("Create super user exception: %s" %(traceback.format_exc()))
         finally:
@@ -194,7 +194,7 @@ class HpcIdInit():
         if self.mc:
             mc = self.getOrCreateMachineCategory(self.mc)
             if mc:
-                self.log("Get machine category = '%s'" %(mc.name))
+                self.log("Get machine category = '%s'" %(self.mc))
             else:    
                 self.log("Failed to get machine category = '%s'" %(self.mc))
         if su:
diff --git a/roles/slurm-common/tasks/installSlurmFromSource.yml b/roles/slurm-common/tasks/installSlurmFromSource.yml
index 95d5fc9..3a3d2f2 100644
--- a/roles/slurm-common/tasks/installSlurmFromSource.yml
+++ b/roles/slurm-common/tasks/installSlurmFromSource.yml
@@ -32,3 +32,8 @@
   args:
     chdir: /tmp/slurm-{{ slurm_version }}
     creates: "{{ slurm_dir }}/bin/srun"
+
+- name: add slurm log rotate config
+  template: src=slurmlog.j2 dest=/etc/logrotate.d/slurm mode=644
+  sudo: true
+
diff --git a/roles/slurm-common/templates/nhclog.j2 b/roles/slurm-common/templates/nhclog.j2
index edba9b8..27dcbce 100644
--- a/roles/slurm-common/templates/nhclog.j2
+++ b/roles/slurm-common/templates/nhclog.j2
@@ -4,6 +4,7 @@
    missingok
    notifempty
    weekly
-   size 200k
+   compress 
+   size 800k
 }
 
diff --git a/roles/slurm-common/templates/slurmlog.j2 b/roles/slurm-common/templates/slurmlog.j2
new file mode 100644
index 0000000..1653dd7
--- /dev/null
+++ b/roles/slurm-common/templates/slurmlog.j2
@@ -0,0 +1,29 @@
+{{ slurmddebug.log }}/slurm*.log
+{
+ compress
+ missingok 
+ nocopytruncate 
+ nocreate 
+ nodelaycompress 
+ nomail  
+ notifempty 
+ noolddir 
+ rotate 5 
+ 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 %}
+  systemctl restart slurmd
+{% else %}
+ postrotate /etc/init.d/slurm reconfig 
+{% endif %}
+ endscript
+}
+
-- 
GitLab