From 3989dd2a6405074753390a6444370e90623c74f5 Mon Sep 17 00:00:00 2001
From: Simon Michnowicz <simon.michnowicz@monash.edu>
Date: Mon, 1 Jul 2019 18:11:30 +1000
Subject: [PATCH] first checkin of role to set service to set semaphores for
 compute nodes

---
 roles/set_semaphore_count/README.md               | 12 ++++++++++++
 roles/set_semaphore_count/tasks/main.yml          | 15 +++++++++++++++
 .../templates/set_semaphores.service.j2           | 10 ++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 roles/set_semaphore_count/README.md
 create mode 100644 roles/set_semaphore_count/tasks/main.yml
 create mode 100644 roles/set_semaphore_count/templates/set_semaphores.service.j2

diff --git a/roles/set_semaphore_count/README.md b/roles/set_semaphore_count/README.md
new file mode 100644
index 00000000..f35566b9
--- /dev/null
+++ b/roles/set_semaphore_count/README.md
@@ -0,0 +1,12 @@
+Some program, i.e. GAMESS, needs a larger number of system semaphores than normal.
+This program creates a systemd file that sets the value on startup, so that it is persistent
+
+To set count:
+echo 500 256000 64 10240 > /proc/sys/kernel/sem
+
+We use a variable SEM_COUNT so users can override the default setting.
+
+use
+- { role: set_semaphore_count } #to use default value
+
+- { role: set_semaphore_count, SEM_COUNT: "200 252000 24 20240" } #to use some other value (the ones here are nonsense for example only)
diff --git a/roles/set_semaphore_count/tasks/main.yml b/roles/set_semaphore_count/tasks/main.yml
new file mode 100644
index 00000000..ad2b5b0c
--- /dev/null
+++ b/roles/set_semaphore_count/tasks/main.yml
@@ -0,0 +1,15 @@
+---
+- name: set the value of the Semaphores
+  set_fact:
+       SEM_COUNT: "500 256000 64 10240"
+  when: SEM_COUNT is not defined
+- name: test value
+  debug: msg="Value of semaphores is {{ SEM_COUNT }} "  #"
+- name: Template set_semaphores.service file
+  template: src=set_semaphores.service.j2 dest=/etc/systemd/system/set_semaphores.service
+  become: true
+  become_user: root
+- name: enable and start set_semaphores service
+  service: name="set_semaphores" state=started enabled=true
+
+
diff --git a/roles/set_semaphore_count/templates/set_semaphores.service.j2 b/roles/set_semaphore_count/templates/set_semaphores.service.j2
new file mode 100644
index 00000000..bb29e4df
--- /dev/null
+++ b/roles/set_semaphore_count/templates/set_semaphores.service.j2
@@ -0,0 +1,10 @@
+[Unit]
+Description=Increase maximum number of semaphores available on the system
+After=network.target
+
+[Service]
+Type=simple
+ExecStart=/bin/sh -c '/usr/bin/echo {{ SEM_COUNT }}   > /proc/sys/kernel/sem'
+
+[Install]
+WantedBy=default.target
-- 
GitLab