adding support to install the mellanox or intel nic

Change-Id: I11c240d53a4d494dbccd76c2e7f415ed0cdfb0eb
diff --git a/roles/compute-node/tasks/main.yml b/roles/compute-node/tasks/main.yml
index cc4a3ee..1965f60 100644
--- a/roles/compute-node/tasks/main.yml
+++ b/roles/compute-node/tasks/main.yml
@@ -62,17 +62,45 @@
     group=root
     mode=0600
 
+- name: Verify Mellanox 40Gb NIC
+  shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c ConnectX-3 || true
+  register: mlx_nic_present
+
+- name: Verify Intel 40Gb NIC
+  shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c "XL710 for 40GbE QSFP+" || true
+  register: intel_nic_present
+
+- name: Fail install if no known NIC is present
+  when: mlx_nic_present.stdout == "0" and intel_nic_present.stdout == "0"
+  fail: msg="No known NICs are present on this compute node"
+
 - name: Verify i40e Driver
   command: modinfo --field=version i40e
   register: i40e_version
+  when: intel_nic_present.stdout == "1"
   changed_when: False
   failed_when: False
   tags:
     - interface_config
 
+- name: Verify mlx4 Driver
+  command: modinfo --field=version mlx4_core
+  register: mlx4_version
+  when: mlx_nic_present.stdout == "1"
+  changed_when: False
+  failed_when: False
+  tags:
+    - interface_config
+
+- name: Update mlx4 Driver
+  include: tasks/mlx4_driver.yml
+  when: mlx_nic_present.stdout == "1" and mlx4_version.stdout != '3.1-1.0.4'
+  tags:
+    - interface_config
+
 - name: Update i40e Driver
   include: tasks/i40e_driver.yml
-  when: i40e_version.stdout != '1.4.25'
+  when: intel_nic_present.stdout == "1" and i40e_version.stdout != '1.4.25'
   tags:
     - interface_config
 
diff --git a/roles/compute-node/tasks/mlx4_driver.yml b/roles/compute-node/tasks/mlx4_driver.yml
new file mode 100644
index 0000000..06219d2
--- /dev/null
+++ b/roles/compute-node/tasks/mlx4_driver.yml
@@ -0,0 +1,43 @@
+---
+- name: Install Prerequesites
+  become: yes
+  apt: name={{ item }} state=installed
+  with_items:
+    - debhelper
+    - autotools-dev
+    - dkms
+    - zlib1g-dev
+
+- name: Unarchive mlx4 driver package
+  unarchive:
+    copy=no
+    src=http://www.mellanox.com/downloads/Drivers/mlnx-en-3.1-1.0.4.tgz
+    dest=/tmp
+
+- name: Install mlx4 driver
+  become: yes
+  command: /tmp/mlnx-en-3.1-1.0.4/install.sh --batch
+
+- name: Remove Build Directory
+  become: yes
+  file:
+    path=/tmp/mlnx-en-3.1-1.0.4
+    state=absent
+
+- name: Remove Build files
+  become: yes
+  file:
+    path=/tmp/mlnx-en-3.1-1.0.4.tgz
+    state=absent
+
+- name: Remove Mellanox Service files
+  become: yes
+  file:
+    path=/etc/init/mlnx-en.conf
+    state=absent
+
+- name: Remove Mellanox Init Script
+  become: yes
+  file:
+    path=/etc/init.d/mlnx-en.d
+    state=absent