Added udev configuration for network interfaces on Ubuntu
This commit is contained in:
parent
0a11cf20aa
commit
7a9911a54d
1 changed files with 21 additions and 1 deletions
|
@ -66,6 +66,8 @@ class network::helper::debian {
|
|||
# $ipaddr:
|
||||
# IP address for interface. Use dhcp for DHCP configuration and none
|
||||
# if interface just needs to be brought up. Defaults to none.
|
||||
# $eaddr:
|
||||
# Ethernet address. Overrides udev configuration.
|
||||
# $netmask:
|
||||
# Netmask for interface. Required only when $ipaddr is used.
|
||||
# $ip6addr:
|
||||
|
@ -83,7 +85,7 @@ class network::helper::debian {
|
|||
# netmask => "255.255.0.0",
|
||||
# }
|
||||
#
|
||||
define network::interface($options = [], $ipaddr = "none", $netmask = "none", $ip6addr = "none", $ip6netmask = "64") {
|
||||
define network::interface($options = [], $ipaddr = "none", $eaddr = "none", $netmask = "none", $ip6addr = "none", $ip6netmask = "64") {
|
||||
|
||||
include network::helper::restart
|
||||
|
||||
|
@ -98,6 +100,15 @@ define network::interface($options = [], $ipaddr = "none", $netmask = "none", $i
|
|||
}
|
||||
}
|
||||
}
|
||||
case $eaddr {
|
||||
none: {
|
||||
$myvar = "macaddress_${name}"
|
||||
$eaddr_real = inline_template("<%= scope.lookupvar(myvar) %>")
|
||||
}
|
||||
default: {
|
||||
$eaddr_real = $eaddr
|
||||
}
|
||||
}
|
||||
|
||||
case $operatingsystem {
|
||||
openbsd: {
|
||||
|
@ -138,6 +149,15 @@ define network::interface($options = [], $ipaddr = "none", $netmask = "none", $i
|
|||
notify => Exec["restart-network"],
|
||||
require => File["/etc/network/interfaces.d", "/etc/network/interfaces.in"],
|
||||
}
|
||||
if $eaddr_real {
|
||||
file { "/etc/udev/rules.d/99-persistent-net-${name}.rules":
|
||||
ensure => present,
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
content => "SUBSYSTEM==\"net\", ACTION==\"add\", ATTR{address}==\"${eaddr_real}\", KERNEL==\"eth*\", NAME=\"${name}\"\n",
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Network module not supported in ${operatingsystem}")
|
||||
|
|
Loading…
Add table
Reference in a new issue