Puppet Class: psick::network

Defined in:
manifests/network.pp

Overview

This class manages network configurations

Parameters:

  • bonding_mode (String) (defaults to: 'active-backup')

    Define bonding mode (default: active-backup)

  • network_template (String) (defaults to: 'psick/network/network.erb')

    The erb template to use, only on RedHad derivatives, for the file /etc/sysconfig/network

  • routes (Hash) (defaults to: {})

    Hash of routes to pass to ::network::mroute define Note: This is not a real class parameter but a key looked up via hiera_hash(‘psick::network::routes’, {})

  • interfaces (Hash) (defaults to: {})

    Hash of interfaces to pass to ::network::interface define Note: This is not a real class parameter but a key looked up via hiera_hash(‘psick::network::interfaces’, {}) Note that this psick automatically adds some default options according to the interface type. You can override them in the provided hash

  • use_netplan (Boolean) (defaults to: false)


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
# File 'manifests/network.pp', line 16

class psick::network (
  String $bonding_mode     = 'active-backup',
  String $network_template = 'psick/network/network.erb',
  Hash $routes             = {},
  Hash $interfaces         = {},
  Boolean $use_netplan     = false,
) {

  contain ::network

  if $use_netplan {
    $default_options = {
    }
    $default_bonding_options = {
    }
    $interfaces.each |$r,$o| {
      if $r =~ /^bond/ {
        $options = $default_options + $default_bonding_options + $o
      } else {
        $options = $default_options + $o
      }
      network::netplan::interface { $r:
        * => $options,
      }
    }
  } else {

    file { '/etc/modprobe.d/bonding.conf':
      ensure => file,
    }
    $routes.each |$r,$o| {
      ::network::mroute { $r: # With example42-network 3.x
    # ::network::route { $r: # With example42-network 4.x
        routes => $o[routes],
      }
    }
    $default_options = {
      onboot     => 'yes',
      'type'     => 'Ethernet',
      template   => "psick/network/interface-${::osfamily}.erb",
      options    => {
        'IPV6INIT'           => 'no',
        'IPV4_FAILURE_FATAL' => 'yes',
      },
      bootproto  => 'none',
      nozeroconf => 'yes',
    }
    $default_bonding_options = {
      'type'         => 'Bond',
      bonding_opts   => "resend_igmp=1 updelay=30000 use_carrier=1 miimon=100 downdelay=100 xmit_hash_policy=0 primary_reselect=0 fail_over_mac=0 arp_validate=0 mode=${bonding_mode} arp_interval=0 ad_select=0",  # lint:ignore:140chars
      bonding_master => 'yes',
    }
    $interfaces.each |$r,$o| {
      if $r =~ /^bond/ {
        $options = $default_options + $default_bonding_options + $o
        file_line { "bonding.conf ${r}":
          line    => "alias netdev-${r} bonding",
          path    => '/etc/modprobe.d/bonding.conf',
          require => File['/etc/modprobe.d/bonding.conf'],
        }
      } else {
        $options = $default_options + $o
      }
      ::network::interface { $r:
        * => $options,
      }
    }

    if $::osfamily == 'RedHat'
    and $network_template != ''
    and $::profile::base::linux::hostname_class != '' {
      file { '/etc/sysconfig/network':
        ensure  => file,
        content => template($network_template),
      }
    }
  }
}