Added support for bridge interfaces on Centos and Fedora

This commit is contained in:
Ossi Salmi 2011-07-20 00:43:05 +03:00 committed by Timo Mkinen
parent c64947271f
commit 6013834928
2 changed files with 17 additions and 2 deletions

View file

@ -112,6 +112,8 @@ class network::hostname {
# Defaults to none. # Defaults to none.
# $ip6netmask: # $ip6netmask:
# IPv6 netmask length. Defaults to 64. # IPv6 netmask length. Defaults to 64.
# $bridge:
# Array of interfaces to add to bridge.
# $options: # $options:
# Custom options for interface (used only on OpenBSD). # Custom options for interface (used only on OpenBSD).
# $postcmd: # $postcmd:
@ -125,7 +127,9 @@ class network::hostname {
# netmask => "255.255.0.0", # netmask => "255.255.0.0",
# } # }
# #
define network::interface($options = [], $ipaddr = "none", $eaddr = "none", $netmask = "none", $ip6addr = "none", $ip6netmask = "64", $postcmd = []) { define network::interface($ipaddr = "none", $eaddr = "none", $netmask = "none",
$ip6addr = "none", $ip6netmask = "64",
$bridge = [], $options = [], $postcmd = []) {
include network::helper::restart include network::helper::restart
@ -162,6 +166,12 @@ define network::interface($options = [], $ipaddr = "none", $eaddr = "none", $net
} }
} }
centos,fedora: { centos,fedora: {
if $bridge {
network::interface { $bridge:
options => [ "BRIDGE=${name}", "LINKDELAY=10" ],
before => Exec["restart-interface-${name}"],
}
}
file { "/etc/sysconfig/network-scripts/ifcfg-${name}": file { "/etc/sysconfig/network-scripts/ifcfg-${name}":
ensure => present, ensure => present,
content => template("network/ifcfg-if.erb"), content => template("network/ifcfg-if.erb"),

View file

@ -1,5 +1,5 @@
DEVICE=<%= name %> DEVICE=<%= name %>
<% if name !~ /bond[0-9]/ && has_variable?("macaddress_" + name) -%> <% if name !~ /(bond|br)[0-9]/ && has_variable?("macaddress_" + name) -%>
HWADDR=<%= scope.lookupvar("macaddress_" + name) %> HWADDR=<%= scope.lookupvar("macaddress_" + name) %>
<% end -%> <% end -%>
ONBOOT=yes ONBOOT=yes
@ -23,6 +23,11 @@ IPV6INIT=yes
IPV6ADDR=<%= ip6addr %>/<%= ip6netmask %> IPV6ADDR=<%= ip6addr %>/<%= ip6netmask %>
<% end -%> <% end -%>
<% end -%> <% end -%>
<% if name =~ /br[0-9]/ -%>
TYPE=Bridge
DELAY=0
LINKDELAY=10
<% end -%>
<% options.each do |val| -%> <% options.each do |val| -%>
<%= val %> <%= val %>
<% end -%> <% end -%>