Defined Type: mofed::interface

Defined in:
manifests/interface.pp

Summary

Manage IPoIB interface

Overview

Examples:

Add IPoIB interface

mofed::interface { 'ib0':
  ensure         => 'present',
  ipaddr         => '10.0.0.1',
  netmask        => '255.255.0.0',
  connected_mode => 'no',
}

Parameters:

  • ipaddr (Optional[Stdlib::Compat::Ip_address]) (defaults to: undef)

    IP address, required when ensure=present

  • netmask (Optional[Stdlib::Compat::Ip_address]) (defaults to: undef)

    Netmask address, required when ensure=present

  • gateway (Optional[Stdlib::Compat::Ip_address]) (defaults to: undef)

    Gateway address.

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Interface ensure value.

  • enable (Boolean) (defaults to: true)

    Boolean of whether to enable the interface at boot.

  • nm_controlled (Optional[Variant[Boolean, Enum['yes','no']]]) (defaults to: undef)

    Value for nm_controlled on interface

  • connected_mode (Enum['yes', 'no']) (defaults to: 'yes')

    The value for setting interface to connected mode.

  • mtu (Optional[Integer]) (defaults to: undef)

    The MTU of the interface.

  • bonding (Boolean) (defaults to: false)

    If this interface is a bonding interface

  • bonding_slaves (Array[String]) (defaults to: [])

    Array of interfaces that should be enslaved in the bonding interface

  • bonding_opts (String) (defaults to: 'mode=active-backup miimon=100')

    The bonding options to use for this bonding interface



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
118
119
120
121
122
123
124
# File 'manifests/interface.pp', line 34

define mofed::interface(
  Enum['present', 'absent'] $ensure           = 'present',
  Optional[Stdlib::Compat::Ip_address] $ipaddr = undef,
  Optional[Stdlib::Compat::Ip_address] $netmask = undef ,
  Optional[Stdlib::Compat::Ip_address] $gateway = undef,
  Boolean $enable = true,
  Optional[Variant[Boolean, Enum['yes','no']]] $nm_controlled = undef,
  Enum['yes', 'no'] $connected_mode           = 'yes',
  Optional[Integer] $mtu = undef,
  Boolean $bonding = false,
  Array[String] $bonding_slaves = [],
  String $bonding_opts = 'mode=active-backup miimon=100',
) {

  if $ensure == 'present' {
    if ! $ipaddr {
      fail('ipaddr is required with ensure=present')
    }
    if ! $netmask {
      fail('netmask is required with ensure=present')
    }
  }

  include mofed

  $onboot = $enable ? {
    true    => 'yes',
    false   => 'no',
    default => $enable,
  }

  $options_extra_redhat = {
    'CONNECTED_MODE' => $connected_mode,
  }

  if $mofed::osfamily == 'RedHat' and versioncmp($mofed::osmajor, '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,
    }
  }

}