From 175bb0aa5ed06bf6a3995fa883e6d261a66d7758 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Sat, 1 Apr 2017 09:14:42 +0100
Subject: [PATCH] Install ipmitool before compute node discovery

---
 ansible/compute-node-discovery.yml | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/ansible/compute-node-discovery.yml b/ansible/compute-node-discovery.yml
index 962d99a48..983d26543 100644
--- a/ansible/compute-node-discovery.yml
+++ b/ansible/compute-node-discovery.yml
@@ -17,7 +17,19 @@
 - name: Ensure compute nodes are PXE booted
   hosts: compute
   gather_facts: no
+  vars:
+    delegate_host: "{{ groups['controllers'][0] }}"
   tasks:
+    - name: Ensure ipmitool is installed
+      yum:
+        name: ipmitool
+        state: installed
+      become: True
+      run_once: True
+      delegate_to: "{{ item }}"
+      with_items:
+        - "{{ hostvars[delegate_host].ansible_host }}"
+
     - name: Set a fact containing the compute node IPMI address
       set_fact:
         ipmi_username: "{{ inspector_ipmi_username }}"
@@ -28,7 +40,7 @@
       command: ipmitool -U {{ ipmi_username }} -P {{ ipmi_password }} -H {{ ipmi_address }} -I lanplus chassis power off
       delegate_to: "{{ item }}"
       with_items:
-        - "{{ hostvars[groups['controllers'][0]].ansible_host }}"
+        - "{{ hostvars[delegate_host].ansible_host }}"
 
     - name: Pause to prevent overwhelming BMCs
       pause:
@@ -38,7 +50,7 @@
       command: ipmitool -U {{ ipmi_username }} -P {{ ipmi_password }} -H {{ ipmi_address }} -I lanplus chassis bootdev pxe
       delegate_to: "{{ item }}"
       with_items:
-        - "{{ hostvars[groups['controllers'][0]].ansible_host }}"
+        - "{{ hostvars[delegate_host].ansible_host }}"
 
     - name: Pause to prevent overwhelming BMCs
       pause:
@@ -48,4 +60,4 @@
       command: ipmitool -U {{ ipmi_username }} -P {{ ipmi_password }} -H {{ ipmi_address }} -I lanplus chassis power on
       delegate_to: "{{ item }}"
       with_items:
-        - "{{ hostvars[groups['controllers'][0]].ansible_host }}"
+        - "{{ hostvars[delegate_host].ansible_host }}"