From 554bf7f7053584b152faa59e199cb8d965399082 Mon Sep 17 00:00:00 2001
From: Chris Hines <chris.hines@monash.edu>
Date: Fri, 29 Jul 2016 04:25:13 +0000
Subject: [PATCH] only install munge if it isn't already installed

---
 roles/slurm-common/tasks/installMungeFromSource.yml | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/roles/slurm-common/tasks/installMungeFromSource.yml b/roles/slurm-common/tasks/installMungeFromSource.yml
index 39610951..b9cdfcdf 100644
--- a/roles/slurm-common/tasks/installMungeFromSource.yml
+++ b/roles/slurm-common/tasks/installMungeFromSource.yml
@@ -1,3 +1,6 @@
+- name: test if munge is already isntalled
+  stat: path="{{ munge_dir }}/bin/munge"
+  register: munge_binary
 
 - name: unarchive munge
   unarchive:
@@ -6,6 +9,7 @@
     copy: no
     dest: /tmp
     creates: /tmp/munge-{{ munge_version }}/configure
+  when: not munge_binary.stat.exists
 
 
 - name: build munge
@@ -13,6 +17,7 @@
   args:
     chdir: /tmp/munge-{{ munge_version }}
     creates: /tmp/munge-{{ munge_version }}/src/munge/munge
+  when: not munge_binary.stat.exists
 
 - name: install munge
   shell: make install
@@ -20,15 +25,17 @@
   args:
     chdir: /tmp/munge-{{ munge_version }}
     creates: "{{ munge_dir }}/bin/munge"
+  when: not munge_binary.stat.exists
 
 - name: set use_systemd
   set_fact: 
     use_systemd: True
-  when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ( ansible_distribution_major_version == "7") 
+  when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ( ansible_distribution_major_version == "7") and not munge_binary.stat.exists
 
 - name: copy init script
   template: dest=/etc/init.d/munge src=munge.initd.j2 mode=755
   sudo: true
+  register: systemd_script_installed
   when: use_systemd is not defined
 
 - name:  copy slurm init script if OS contains systemd
@@ -39,4 +46,4 @@
 - name: reload systemd
   shell: systemctl daemon-reload
   sudo: true
-  when: use_systemd is defined
+  when: use_systemd is defined and systemd_script_installed|changed
-- 
GitLab