Puppet Class: g_server::network

Defined in:
manifests/network.pp

Summary

Setups network interfaces and hosts.

Overview

Parameters:

  • internal_tld (String) (defaults to: 'internal')

    Domain used for hostname on internal interfaces

  • additional_hosts (Array) (defaults to: [])

    Additional hosts passed to ::hosts

  • interfaces (Hash[String, Optional[Hash]]) (defaults to: {})

    Sets interfaces using g_server::network::iface

  • enable_macvlan (Boolean) (defaults to: false)

    Enables or disables installing scripts for macvlan interfaces support



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

class g_server::network(
  String $internal_tld = 'internal',
  Array $additional_hosts = [],
  Hash[String, Optional[Hash]] $interfaces = {},
  Boolean $enable_macvlan = false
){

  $internal_hostname = "${::facts['networking']['hostname']}.${internal_tld}"

  case $::osfamily {
    'Gentoo': {
      class { '::g_server::network::gentoo::network': }
    }
    default: {
      class { 'network':
        ipv6enable => true
      }
    }
  }

  class { 'hosts':
    hosts => $additional_hosts
  }

  $_interfaces = Hash($interfaces.map | $k, $v | {
    [
      $k,
      $v?{
        undef => {},
        default => $v
      }
    ]
  })

  create_resources(g_server::network::iface, $_interfaces)

  $macvlan_ensure = $enable_macvlan?{
    true    => present,
    default => absent
  }
  if $::osfamily == 'RedHat' {
    ['ifdown-macvlan', 'ifup-macvlan'].each | $f | {
      file { "/etc/sysconfig/network-scripts/${f}":
        ensure => $macvlan_ensure,
        mode   => 'a+rx,u+w',
        source => "puppet:///modules/g_server/network-scripts/${f}"
      }
    }
  }
}