L23network: create_br_iface can build OVS bonds

Example:
    l23network::l3::create_br_iface {'pvt':
      interface => ['eth0', 'eth2'],
      ipaddr    => $public_ipaddr,
      netmask   => $public_netmask,
      ovs_bond_name => 'bond1',
      ovs_bond_options => [],
    } ->
    l23network::l2::port{'vl10':
      bridge  => 'pvt',
      type    => 'internal', # If you need use this interface in L3 utilities (ex: ifconfig)
      port_options => ['tag=10'],
    } ->
    l23network::l2::port{'vl20':
      bridge  => 'pvt',
      type    => 'internal', # If you need use this interface in L3 utilities (ex: ifconfig)
      port_options => ['tag=20'],
    }
    # NOTE! first you must cofigure L2 network (or L2+L3 by create_br_iface, but be carefuly)
    l23network::l3::ifconfig {'vl10': ipaddr=>'192.168.210.4' }
    l23network::l3::ifconfig {'vl20': ipaddr=>'192.168.220.4' }
This commit is contained in:
Sergey Vasilenko 2013-03-27 14:57:01 +04:00
parent 1685902129
commit 37f21370de
2 changed files with 40 additions and 21 deletions

View File

@ -9,7 +9,9 @@
# Bridge name
#
# [*interface*]
# Interface, that will be added to the bridge.
# Interface, that will be added to the bridge. If You set array of interface names --
# Open vSwitch bond will be builded on its. In this case You must set ovs_bond_name and
# ovs_bond_options options.3
#
# [*ipaddr*]
# IP address for port in bridge.
@ -34,9 +36,9 @@
# DNS domain to search for
#
define l23network::l3::create_br_iface (
$interface, #TODO: if interface is array -- create bond, using bond_options.
$bridge,
$interface,
$ipaddr,
$bridge = $name,
$netmask = '255.255.255.0',
$gateway = undef,
$se = true,
@ -49,9 +51,9 @@ define l23network::l3::create_br_iface (
$lnx_interface_bond_mode = undef,
$lnx_interface_bond_miimon = 100,
$lnx_interface_bond_lacp_rate = 1,
$lnx_interface_order_prefix = false,
$ovs_bond_name = 'bond0',
$ovs_bond_options = [],
$interface_order_prefix = false,
){
if ! $external_ids {
$ext_ids = "bridge-id=${bridge}"
@ -64,15 +66,32 @@ define l23network::l3::create_br_iface (
} else {
$gateway_ip_address_for_newly_created_interface = undef
}
# Build ovs bridge
l23network::l2::bridge {$bridge:
skip_existing => $se,
external_ids => $ext_ids,
}
if is_array($interface) {
# Build ovs bridge, contains ovs bond with givet interfaces
l23network::l2::bond {$ovs_bond_name:
bridge => $bridge,
ports => $interface,
options => $ovs_bond_options,
skip_existing => $se,
require => L23network::L2::Bridge[$bridge]
} ->
l23network::l3::ifconfig {$interface:
ipaddr => 'none',
require => L23network::L2::Bond[$ovs_bond_name],
before => L23network::L3::Ifconfig[$bridge]
}
} else {
# Build ovs bridge, contains one interface
l23network::l2::port {$interface:
bridge => $bridge,
skip_existing => $se,
require => L23network::L2::Bridge[$bridge]
}
} ->
l23network::l3::ifconfig {$interface:
ipaddr => 'none',
vlandev => $lnx_interface_vlandev,
@ -80,7 +99,9 @@ define l23network::l3::create_br_iface (
bond_mode => $lnx_interface_bond_mode,
bond_miimon => $lnx_interface_bond_miimon,
bond_lacp_rate => $lnx_interface_bond_lacp_rate,
ifname_order_prefix => $lnx_interface_order_prefix,
ifname_order_prefix => $interface_order_prefix,
before => L23network::L3::Ifconfig[$bridge]
}
}
l23network::l3::ifconfig {$bridge:
ipaddr => $ipaddr,
@ -90,6 +111,5 @@ define l23network::l3::create_br_iface (
dns_domain => $dns_domain,
dns_search => $dns_search,
ifname_order_prefix => 'ovs',
require => L23network::L3::Ifconfig[$interface],
}
}

View File

@ -206,8 +206,7 @@ define l23network::l3::ifconfig (
content => template('l23network/interfaces.erb'),
}
}
#File[$interfaces] -> File[$if_files_dir]
#File<| title == $interfaces |> -> File<| title == $if_files_dir |>
File<| title == $interfaces |> -> File<| title == $if_files_dir |>
}
if ! defined(File[$if_files_dir]) {
@ -218,13 +217,13 @@ define l23network::l3::ifconfig (
recurse => true,
}
}
File<| title == $if_files_dir |> -> File<| title == $interface_file |>
file {$interface_file:
ensure => present,
owner => 'root',
mode => '0644',
content => template("l23network/ipconfig_${::osfamily}_${method}.erb"),
require => File[$if_files_dir],
}
notify {"ifconfig_${interface}": message=>"Interface:${interface} IP:${ipaddr}/${netmask}", withpath=>false} ->