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:
parent
1685902129
commit
37f21370de
@ -9,7 +9,9 @@
|
|||||||
# Bridge name
|
# Bridge name
|
||||||
#
|
#
|
||||||
# [*interface*]
|
# [*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*]
|
# [*ipaddr*]
|
||||||
# IP address for port in bridge.
|
# IP address for port in bridge.
|
||||||
@ -34,9 +36,9 @@
|
|||||||
# DNS domain to search for
|
# DNS domain to search for
|
||||||
#
|
#
|
||||||
define l23network::l3::create_br_iface (
|
define l23network::l3::create_br_iface (
|
||||||
$interface, #TODO: if interface is array -- create bond, using bond_options.
|
$interface,
|
||||||
$bridge,
|
|
||||||
$ipaddr,
|
$ipaddr,
|
||||||
|
$bridge = $name,
|
||||||
$netmask = '255.255.255.0',
|
$netmask = '255.255.255.0',
|
||||||
$gateway = undef,
|
$gateway = undef,
|
||||||
$se = true,
|
$se = true,
|
||||||
@ -49,9 +51,9 @@ define l23network::l3::create_br_iface (
|
|||||||
$lnx_interface_bond_mode = undef,
|
$lnx_interface_bond_mode = undef,
|
||||||
$lnx_interface_bond_miimon = 100,
|
$lnx_interface_bond_miimon = 100,
|
||||||
$lnx_interface_bond_lacp_rate = 1,
|
$lnx_interface_bond_lacp_rate = 1,
|
||||||
$lnx_interface_order_prefix = false,
|
|
||||||
$ovs_bond_name = 'bond0',
|
$ovs_bond_name = 'bond0',
|
||||||
$ovs_bond_options = [],
|
$ovs_bond_options = [],
|
||||||
|
$interface_order_prefix = false,
|
||||||
){
|
){
|
||||||
if ! $external_ids {
|
if ! $external_ids {
|
||||||
$ext_ids = "bridge-id=${bridge}"
|
$ext_ids = "bridge-id=${bridge}"
|
||||||
@ -64,15 +66,32 @@ define l23network::l3::create_br_iface (
|
|||||||
} else {
|
} else {
|
||||||
$gateway_ip_address_for_newly_created_interface = undef
|
$gateway_ip_address_for_newly_created_interface = undef
|
||||||
}
|
}
|
||||||
|
# Build ovs bridge
|
||||||
l23network::l2::bridge {$bridge:
|
l23network::l2::bridge {$bridge:
|
||||||
skip_existing => $se,
|
skip_existing => $se,
|
||||||
external_ids => $ext_ids,
|
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:
|
l23network::l2::port {$interface:
|
||||||
bridge => $bridge,
|
bridge => $bridge,
|
||||||
skip_existing => $se,
|
skip_existing => $se,
|
||||||
require => L23network::L2::Bridge[$bridge]
|
require => L23network::L2::Bridge[$bridge]
|
||||||
}
|
} ->
|
||||||
l23network::l3::ifconfig {$interface:
|
l23network::l3::ifconfig {$interface:
|
||||||
ipaddr => 'none',
|
ipaddr => 'none',
|
||||||
vlandev => $lnx_interface_vlandev,
|
vlandev => $lnx_interface_vlandev,
|
||||||
@ -80,7 +99,9 @@ define l23network::l3::create_br_iface (
|
|||||||
bond_mode => $lnx_interface_bond_mode,
|
bond_mode => $lnx_interface_bond_mode,
|
||||||
bond_miimon => $lnx_interface_bond_miimon,
|
bond_miimon => $lnx_interface_bond_miimon,
|
||||||
bond_lacp_rate => $lnx_interface_bond_lacp_rate,
|
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:
|
l23network::l3::ifconfig {$bridge:
|
||||||
ipaddr => $ipaddr,
|
ipaddr => $ipaddr,
|
||||||
@ -90,6 +111,5 @@ define l23network::l3::create_br_iface (
|
|||||||
dns_domain => $dns_domain,
|
dns_domain => $dns_domain,
|
||||||
dns_search => $dns_search,
|
dns_search => $dns_search,
|
||||||
ifname_order_prefix => 'ovs',
|
ifname_order_prefix => 'ovs',
|
||||||
require => L23network::L3::Ifconfig[$interface],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,7 @@ define l23network::l3::ifconfig (
|
|||||||
content => template('l23network/interfaces.erb'),
|
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]) {
|
if ! defined(File[$if_files_dir]) {
|
||||||
@ -218,13 +217,13 @@ define l23network::l3::ifconfig (
|
|||||||
recurse => true,
|
recurse => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File<| title == $if_files_dir |> -> File<| title == $interface_file |>
|
||||||
|
|
||||||
file {$interface_file:
|
file {$interface_file:
|
||||||
ensure => present,
|
ensure => present,
|
||||||
owner => 'root',
|
owner => 'root',
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
content => template("l23network/ipconfig_${::osfamily}_${method}.erb"),
|
content => template("l23network/ipconfig_${::osfamily}_${method}.erb"),
|
||||||
require => File[$if_files_dir],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notify {"ifconfig_${interface}": message=>"Interface:${interface} IP:${ipaddr}/${netmask}", withpath=>false} ->
|
notify {"ifconfig_${interface}": message=>"Interface:${interface} IP:${ipaddr}/${netmask}", withpath=>false} ->
|
||||||
|
Loading…
Reference in New Issue
Block a user