Skip to content

Instantly share code, notes, and snippets.

@coderforhire
Created May 13, 2013 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderforhire/5569399 to your computer and use it in GitHub Desktop.
Save coderforhire/5569399 to your computer and use it in GitHub Desktop.
# /etc/puppet/modules/netif/manifests/eth.pp
# handle ethernet and VLAN ethernet device type configuration
#
define netif::eth ($ifaddr = "", $ifaddr6 = "", $aliases = [], $aliases6 = [], $onboot = "yes" , $mtu="1500")
{
$ifname = $name
# filename
$eth_file = "/etc/sysconfig/network-scripts/ifcfg-${ifname}"
# set up regular eth ifcfg file
file { "$eth_file":
mode => 644 ,
owner => root ,
group => root ,
# backup => sysconfig
ensure => file ,
content => template("netif/eth.erb"),
notify => Service[network] ,
}
}
define netif::eth_vlan ($ifaddr = "", $onboot = "yes" , $mtu)
{
$ifname = $name
# filename
$eth_file = "/etc/sysconfig/network-scripts/ifcfg-${ifname}"
# set up vlan eth ifcfg file
file { "$eth_file":
mode => 644 ,
owner => root ,
group => root ,
# backup => sysconfig
ensure => file ,
content => template("netif/eth_vlan.erb"),
notify => Service[network] ,
}
}
~
class netif {
# include stdlib
# other stuff depends on network service
service { "network" :
ensure => true ,
enable => true ,
}
# add openib service if we have an ib interface
if ($::interfaces =~ /ib/) {
service { "openibd" :
ensure => true ,
enable => true ,
}
}
}
# interface reusable type
# default MTU is set in the individual interface defined types
define netif::interface (
$ifaddr = "",
$ifaddr6 = "",
$aliases = [],
$aliases6 = [],
$slaves = [] ,
$onboot = "yes",
$onparent = "yes" ,
$mtu,
$routes = undef,
$routes6 = undef )
{
# switch on interface name
case $name {
# catch alias first since it might match other stuff
/^.*:.*$/ : {
netif::alias { $name :
ifaddr => $ifaddr ,
onparent => $onparent ,
mtu => $mtu,
}
}
# regular ethernet interface.
/^eth\d+$/ : {
netif::eth { $name :
ifaddr => $ifaddr ,
mtu => $mtu,
ifaddr6 => $ifaddr6 ,
aliases => $aliases ,
aliases6 => $aliases6 ,
}
... snip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment