Skip to content
Snippets Groups Projects
Commit 7a426a04 authored by Shahaan Ayyub's avatar Shahaan Ayyub
Browse files

Merge github.com:monash-merc/ansible_cluster_in_a_box

parents cac9dd66 a64677fb
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@ from karaage.institutes.models import Institute
from karaage.machines.models import MachineCategory
from karaage.people.models import Person, Group
CONSOLE_DEBUG = False
class HpcIdInit():
import django
django.setup()
......@@ -17,6 +19,9 @@ class HpcIdInit():
self.path = configfile
self.password = password
self.debug = debug
if not debug:
self.logfile = open("/tmp/kg_init.log", "w")
if self.path and os.path.exists(self.path):
with open(self.path) as data:
config_data = json.load(data)
......@@ -26,9 +31,14 @@ class HpcIdInit():
else:
log("Invalid input data")
def __del__(self):
self.logfile.close()
def log(self, message):
if self.debug:
print message
else:
self.logfile.write(message + "\n")
def getGroup(self, name):
group = None
......@@ -173,6 +183,7 @@ class HpcIdInit():
try:
delegates = institute.delegates.all().filter(username = su.username)
if len(delegates) == 0:
self.log("Create institution delegate %s"%(su.username))
institute.delegates.add(su)
except:
result = False
......@@ -216,7 +227,7 @@ def main(argv):
if len(sys.argv) > 2:
config_path = argv[0]
password = argv[1]
debug = True
debug = CONSOLE_DEBUG
if len(sys.argv) > 3:
debug = argv[2]
init = HpcIdInit(config_path, password, debug)
......
......@@ -36,4 +36,3 @@
- name: add slurm log rotate config
template: src=slurmlog.j2 dest=/etc/logrotate.d/slurm mode=644
sudo: true
{{ 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
......
......@@ -32,3 +32,7 @@
sudo: true
when: slurm_dir is not defined
- name: add slurm db log rotate config
template: src=slurmdblog.j2 dest=/etc/logrotate.d/slurmdb mode=644
sudo: true
{{ 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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment