Defined Type: network::if::promisc

Defined in:
manifests/if/promisc.pp

Overview

Definition: network::if::promisc

Creates a promiscuous interface.

Parameters:

$ensure        - required - up|down
$macaddress    - optional, defaults to macaddress_$title
$manage_hwaddr - optional - defaults to true
$bootproto     - optional, defaults to undef ('none')
$userctl       - optional
$mtu           - optional
$ethtool_opts  - optional
$promisc       - defaults to true

Actions:

Deploys the file /etc/sysconfig/network-scripts/ifcfg-$name.

Requires:

Service['network']

Sample Usage:

network::if::promisc { 'eth1':
  ensure => 'up',
}

network::if::promisc { 'eth1':
  ensure => 'up',
  macaddress => aa:bb:cc:dd:ee:ff,
}

Authors:

Elyse Salberg <elyse_salberg@putnam.com>

Copyright © 2015 Elyse Salberg, unless otherwise noted.

Parameters:

  • ensure (Any)
  • macaddress (Any) (defaults to: undef)
  • manage_hwaddr (Any) (defaults to: true)
  • bootproto (Any) (defaults to: undef)
  • userctl (Any) (defaults to: false)
  • mtu (Any) (defaults to: undef)
  • ethtool_opts (Any) (defaults to: undef)
  • restart (Any) (defaults to: true)
  • promisc (Any) (defaults to: true)


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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'manifests/if/promisc.pp', line 43

define network::if::promisc (
  $ensure,
  $macaddress    = undef,
  $manage_hwaddr = true,
  $bootproto     = undef,
  $userctl       = false,
  $mtu           = undef,
  $ethtool_opts  = undef,
  $restart       = true,
  $promisc       = true,
) {
  include '::network'

  $interface = $name

  if ! is_mac_address($macaddress) {
    # Strip off any tailing VLAN (ie eth5.90 -> eth5).
    $title_clean = regsubst($title,'^(\w+)\.\d+$','\1')
    $macaddy = getvar("::macaddress_${title_clean}")
  } else {
    $macaddy = $macaddress
  }

  # Validate our regular expressions
  $states = [ '^up$', '^down$' ]
  validate_re($ensure, $states, '$ensure must be either "up" or "down".')

  # Validate booleans
  validate_bool($userctl)
  validate_bool($manage_hwaddr)
  validate_bool($restart)
  validate_bool($promisc)

  # Validate our data
  if ! is_mac_address($macaddy) {
    fail("${macaddy} is not a MAC address.")
  }

  $onboot = $ensure ? {
    'up'    => 'yes',
    'down'  => 'no',
    default => undef,
  }

  if $promisc {
    case $::operatingsystem {
      /^(RedHat|CentOS|OEL|OracleLinux|SLC|Scientific)$/: {
        case $::operatingsystemmajrelease {
          '5': {
            $ifup_source   = "puppet:///modules/${module_name}/promisc/ifup-local-promisc_5"
            $ifdown_source = "puppet:///modules/${module_name}/promisc/ifdown-local-promisc_5"
          }
          '6','7': {
            $ifup_source   = "puppet:///modules/${module_name}/promisc/ifup-local-promisc_6"
            $ifdown_source = "puppet:///modules/${module_name}/promisc/ifdown-local-promisc_6"
          }
          default: {
            fail('Promiscuous network setup is currently only available for EL 5, 6, and 7.')
          }
        }

        file { [ '/sbin/ifup-local', '/sbin/ifdown-local' ]:
          ensure  => 'present',
          owner   => 'root',
          group   => 'root',
          mode    => '0755',
          content => '#!/bin/bash',
          replace => false,
        }
        file {'ifup-local-promisc':
          ensure => 'file',
          path   => '/sbin/ifup-local-promisc',
          owner  => 'root',
          group  => 'root',
          mode   => '0755',
          source => $ifup_source,
        }
        file {'ifdown-local-promisc':
          ensure => 'file',
          path   => '/sbin/ifdown-local-promisc',
          owner  => 'root',
          group  => 'root',
          mode   => '0755',
          source => $ifdown_source,
        }
        file_line { 'ifup-local-promisc':
          path    => '/sbin/ifup-local',
          line    => '/sbin/ifup-local-promisc',
          require => [ File['/sbin/ifup-local'],File['/sbin/ifup-local-promisc'] ],
        }
        file_line { 'ifdown-local-promisc':
          path    => '/sbin/ifdown-local',
          line    => '/sbin/ifdown-local-promisc',
          require => [ File['/sbin/ifdown-local'],File['/sbin/ifdown-local-promisc'] ],
        }
      }
      default: {
        notice('Promiscuous network setup currently is only available for RedHat.')
      }
    }
  }

  network_if_base { $title:
    ensure        => $ensure,
    ipaddress     => '',
    netmask       => '',
    gateway       => '',
    macaddress    => $macaddy,
    manage_hwaddr => $manage_hwaddr,
    bootproto     => 'none',
    ipv6address   => '',
    ipv6gateway   => '',
    mtu           => $mtu,
    ethtool_opts  => $ethtool_opts,
    promisc       => $promisc,
  }
}