-
Notifications
You must be signed in to change notification settings - Fork 7
/
interface.pp
117 lines (109 loc) · 3.77 KB
/
interface.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# @summary Manage IPoIB interface
#
# @example Creates the ifcfg file for an IBoIP interface
# infiniband::interface { 'ib0':
# ipaddr => '192.168.1.1',
# netmask => '255.255.255.0',
# }
#
#
# @param name
# The resource title. Sets the interfaces name, for example 'ib0'.
# @param ipaddr
# The IPADDR for the infiniband interface.
# @param netmask
# The NETMASK for the infiniband interface.
# @param gateway
# The GATEWAY for the infiniband interface.
# @param ensure
# Sets if the infiniband::interface should be present or absent.
# @param enable
# Sets if the infiniband::interface should be enabled at boot.
# @param nm_controlled
# Value for nm_controlled on interface
# @param connected_mode
# The CONNECTED_MODE value for the infiniband interface.
# @param mtu
# The MTU for the infiniband interface.
# @param bonding
# If this interface is a bonding interface (true/false); defaults to false
# @param bonding_slaves
# Array of interfaces that should be enslaved in the bonding interface
# @param bonding_opts
# The bonding options to use for this bonding interface
#
define infiniband::interface (
Stdlib::Compat::Ip_address $ipaddr,
Stdlib::Compat::Ip_address $netmask,
Optional[Stdlib::Compat::Ip_address] $gateway = undef,
Enum['present', 'absent'] $ensure = 'present',
Boolean $enable = true,
Enum['yes', 'no'] $connected_mode = 'yes',
Optional[Variant[Boolean, Enum['yes','no']]] $nm_controlled = undef,
Optional[Integer] $mtu = undef,
Boolean $bonding = false,
Array[String] $bonding_slaves = [],
String $bonding_opts = 'mode=active-backup miimon=100',
) {
$onboot = $enable ? {
String => $enable,
Boolean => $enable ? {
true => 'yes',
false => 'no',
},
}
$options_extra_redhat = {
'CONNECTED_MODE' => $connected_mode,
}
if $::osfamily == 'RedHat' and versioncmp($::operatingsystemmajrelease, '8') >= 0 {
$_nm_controlled = pick($nm_controlled, false)
} else {
$_nm_controlled = pick($nm_controlled, 'no')
}
if $bonding {
if empty($bonding_slaves) {
fail("No slave interfaces given for bonding interface ${name}")
}
# Setup interfaces for the slaves
$bonding_slaves.each |String $ifname| {
network::interface { $ifname:
ensure => $ensure,
enable => $enable,
onboot => $onboot,
type => 'InfiniBand',
master => $name,
slave => 'yes',
nm_controlled => $_nm_controlled,
mtu => $mtu,
options_extra_redhat => $options_extra_redhat,
}
}
# Setup the bonding interface
network::interface { $name:
ensure => $ensure,
enable => $enable,
onboot => $onboot,
type => 'Bond',
ipaddress => $ipaddr,
netmask => $netmask,
gateway => $gateway,
bonding_master => 'yes',
bonding_opts => $bonding_opts,
nm_controlled => $_nm_controlled,
mtu => $mtu,
}
} else {
network::interface { $name:
ensure => $ensure,
enable => $enable,
onboot => $onboot,
type => 'InfiniBand',
ipaddress => $ipaddr,
netmask => $netmask,
gateway => $gateway,
nm_controlled => $_nm_controlled,
mtu => $mtu,
options_extra_redhat => $options_extra_redhat,
}
}
}