Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mcc2
ansible_cluster_in_a_box
Commits
b1ed1fb6
Commit
b1ed1fb6
authored
Nov 03, 2015
by
Chris Hines
Browse files
add a role to install the mellanox driver on CentOS 7
parent
a8bba05b
Changes
4
Hide whitespace changes
Inline
Side-by-side
roles/mellanox_drivers/files/mlnx_install.sh
0 → 100755
View file @
b1ed1fb6
#!/bin/sh
# A CRUDE Script to install Mellanox OFED drivers
# Philip.Chan@monash.edu
#
# TODO: check if MLNX_OFED is already installed!
# TODO: check kernel...
KERN
=
`
uname
-r
`
if
[
"
$KERN
"
!=
"3.10.0-229.14.1.el7.x86_64"
]
then
echo
"Oops! Did you forget to reboot?"
echo
"Kernel version has to be 3.10.0-229.14.1.el7.x86_64"
exit
1
fi
sudo
yum
install
-y
pciutils gcc-gfortran libxml2-python tcsh libnl lsof tcl tk perl
sudo
yum
install
-y
gtk2 atk cairo
tar
xzvf MLNX_OFED_LINUX-3.1-1.0.3-rhel7.1-x86_64-ext.tgz
cd
MLNX_OFED_LINUX-3.1-1.0.3-rhel7.1-x86_64-ext
sudo
./mlnxofedinstall
-q
cd
..
tmpfile
=
"/tmp/ifcfg.pc"
rm
-f
$tmpfile
./set_ifcfg.pl
$tmpfile
if
[
-f
$tmpfile
]
then
echo
"Attempting to install ifcfg-ens6"
if
[
-f
/etc/sysconfig/network-scripts/ifcfg-ens6
]
then
echo
"/etc/sysconfig/network-scripts/ifcfg-ens6 already exists!"
grep
IP /etc/sysconfig/network-scripts/ifcfg-ens6
echo
"bailing!"
else
sudo cp
-ip
$tmpfile
/etc/sysconfig/network-scripts/ifcfg-ens6
sudo chown
root:root /etc/sysconfig/network-scripts/ifcfg-ens6
cd
/etc/sysconfig/network-scripts
sudo
./ifup ens6
ping
-c
1 172.16.228.1
fi
fi
exit
0
roles/mellanox_drivers/files/set_ifcfg.pl
0 → 100755
View file @
b1ed1fb6
#!/usr/bin/perl
#
# Assumes Mellanox NIC is named as ens6
# Philip.Chan@monash.edu
#
# Usage:
# ./set_ifcfg.pl [<tmpfilename>]
# To be used within the mlnx_install.sh
#
my
$outfile
=
shift
@ARGV
;
$outfile
=
"
tmp.ifcfg
"
if
(
!
defined
$outfile
);
sub
get_index
{
my
$hn
=
shift
;
my
$maxhosts
=
32
;
if
(
$hn
=~
/hc(\d+)/
)
{
return
33
+
$
1
if
(
$
1
<
$maxhosts
);
}
if
(
$hn
=~
/hs(\d+)/
)
{
return
1
+
$
1
if
(
$
1
<
$maxhosts
);
}
return
0
;
}
my
$hostname
=
`
/bin/hostname
`;
my
$x
=
get_index
(
$hostname
);
die
"
Unable to parse hostname
$hostname
"
if
(
$x
eq
'
0
');
my
$ip
=
"
172.16.229.
$x
";
print
"
Assigning
$ip
to
$hostname
\n
";
open
OUT
,
"
>
$outfile
"
or
die
"
Failed to create output file
$outfile
!
";
print
OUT
"
DEVICE=ens6
\n
";
print
OUT
"
ONBOOT=yes
\n
";
print
OUT
"
NM_CONTROLLED=no
\n
";
print
OUT
"
BOOTPROTO=none
\n
";
print
OUT
"
IPADDR=
$ip
\n
";
print
OUT
"
PREFIX=22
\n
";
print
OUT
"
MTU=9000
\n
";
close
OUT
;
exit
0
;
roles/mellanox_drivers/tasks/main.yml
0 → 100644
View file @
b1ed1fb6
---
-
name
:
restart machine
command
:
shutdown -r now "Ansible updates triggered"
async
:
0
poll
:
0
ignore_errors
:
true
-
name
:
waiting for server to come back
local_action
:
wait_for host={{ inventory_hostname }}
state=started
sudo
:
false
-
name
:
test for existing installation of drivers
command
:
ibv_devinfo
sudo
:
true
register
:
drivers_installed
ignore_errors
:
true
-
name
:
copy driver source
unarchive
:
copy=yes src=MLNX_OFED_LINUX-3.1-1.0.3-rhel7.1-x86_64-ext.tgz dest=/tmp/MLNX_OFED_LINUX-3.1-1.0.3-rhel7.1-x86_64-ext
sudo
:
true
when
:
drivers_installed|failed and ansible_os_family=="RedHat" and ansible_distribution_major_version == "7"
-
name
:
install drivers
command
:
./mlnxofedinstall -q
args
:
path
:
/tmp/MLNX_OFED_LINUX-3.1-1.0.3-rhel7.1-x86_64-ext
sudo
:
true
when
:
drivers_installed failed and ansible_distribution_major_version == "7"
-
name
:
get IP address
command
:
./scripts/map_ib_ip.pl {{ inventory_hostname }}
local_action
:
true
register
:
ip_address
-
name
:
template IP address
template
:
dest=/etc/sysconfig/network-scripts/ifcfg-ens6 source=ifcfg-ens6.j2 owner=root group=root
sudo
:
true
when
:
ansible_distribution_major_version == "7"
-
name
:
bring up interface
command
:
ifup ens6
sudo
:
true
when
:
ansible_distribution_major_version == "7"
roles/mellanox_drivers/templates/ifcfg-ens6.j2
0 → 100644
View file @
b1ed1fb6
DEVICE=ens6
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR={{ ip_address.stdout }}
PREFIX=22
MTU=9000
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment