Puppet Class: psick::network::example42

Defined in:
manifests/network/example42.pp

Overview

This class manages network configurations using defines similar and compatible with example42-network module ones It’s declare in psick::network if you set in Hiera:

psick::network::module: 'example42-network'

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 of routes to pass to ::network::mroute define Note: This is not a real class parameter but a key looked up via lookup(‘psick::network::routes’, Hash, ‘deep’, {})

  • interfaces

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



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

class psick::network::example42 (
  String $bonding_mode     = 'active-backup',
  String $network_template = 'psick/network/network.erb',
) {
  file { '/etc/modprobe.d/bonding.conf':
    ensure => file,
  }
  $routes = lookup('psick::network::routes', Hash, 'deep', {})
  $routes.each |$r,$o| {
    psick::network::route { $r:
      routes => $o[routes],
    }
  }
  $default_options = {
    onboot     => 'yes',
    'type'     => 'Ethernet',
    template   => "psick/network/interface-${facts['os']['family']}.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",
    bonding_master => 'yes',
  }
  $interfaces = lookup('psick::network::interfaces', Hash, 'deep', {})
  $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
    }
    psick::network::interface { $r:
      * => $options,
    }
  }

  if $facts['os']['family'] == 'RedHat'
  and $network_template != '' {
    file { '/etc/sysconfig/network':
      ensure  => file,
      content => template($network_template),
    }
  }
}