Skip to content
Snippets Groups Projects

Network extdouble

Merged Riccardo Bucchi requested to merge network_extdouble into master
1 file
+ 81
50
Compare changes
  • Side-by-side
  • Inline
class iaas::profile::neutron::router (
$public_interface = hiera('iaas::public_interface', undef),
$public_gateway = hiera('iaas::public_gateway', undef),
$external_device = undef,
$external_network = hiera('iaas::profile::neutron::external_network', undef),
$external_gateway = hiera('iaas::profile::neutron::external_gateway', undef),
$external_device1 = undef,
$external_network1 = hiera('iaas::profile::neutron::external_network1', undef),
$external_gateway1 = hiera('iaas::profile::neutron::external_gateway1', undef),
$external_device2 = undef,
$external_network2 = hiera('iaas::profile::neutron::external_network2', undef),
$external_gateway2 = hiera('iaas::profile::neutron::external_gateway2', undef),
$neutron_password = hiera('iaas::profile::neutron::password', undef),
$neutron_secret = hiera('iaas::profile::neutron::secret', undef),
@@ -14,6 +19,7 @@ class iaas::profile::neutron::router (
$mtu = 1438,
) {
sysctl::value { "net.ipv4.ip_forward": value => "1" }
sysctl::value { "net.ipv4.conf.all.rp_filter": value => "0" }
sysctl::value { "net.ipv4.conf.default.rp_filter": value => "0" }
@@ -45,7 +51,7 @@ class iaas::profile::neutron::router (
}
class { '::neutron::agents::l3':
external_network_bridge => 'br-ex',
external_network_bridge => ' ',
use_namespaces => true,
router_delete_namespaces => true,
ha_enabled => true,
@@ -67,7 +73,7 @@ class iaas::profile::neutron::router (
}
class { '::neutron::agents::vpnaas':
external_network_bridge => "br-ex",
external_network_bridge => ' ',
}
class { '::neutron::agents::lbaas': }
class { '::neutron::agents::metering': }
@@ -84,85 +90,176 @@ class iaas::profile::neutron::router (
enabled => true,
}
if $ipaddress_br_ex == '' {
if $ipaddress_br_ex1 == '' {
$local_ip = $::facts["ipaddress_${public_interface}"]
} else {
$local_ip = $::ipaddress_br_ex
$local_ip = $::ipaddress_br_ex1
}
if $external_device2 {
$bridge_mappings1="physnet1:br-ex1"
$bridge_mappings2="physnet2:br-ex2"
} else {
$bridge_mappings1='physnet1:br-ex1'
}
class { '::neutron::agents::ml2::ovs':
enable_tunneling => true,
local_ip => $local_ip,
enabled => true,
tunnel_types => ['gre'],
bridge_mappings => ['external:br-ex'],
bridge_mappings => [$bridge_mappings1,$bridge_mappings2],
require => File['etc_default_neutron-server'],
}
$_external_device = device_for_network($external_network)
notify { "external device: $_external_device -- external network: $external_network":
loglevel => alert,
}
notify { "OperatingSystem: $::operatingsystem ; OperatingSystemRelease: $::operatingsystemrelease":
loglevel => alert,
}
if $_external_device != 'br_ex' {
# notify { "br-ex1: $::brex1_eval":
# loglevel => alert,
# }
# notify { "br-ex2: $::brex2_eval":
# loglevel => alert,
# }
# notify { "external device1: $_external_device1 -- external network: $external_network1":
# loglevel => alert,
# }
## Store initial configuration from the public interface (assigned by DHCP) to restore on br-ex
$public_ipaddress = $::facts["ipaddress_${public_interface}"]
$public_netmask = $::facts["netmask_${public_interface}"]
$public_macaddr = $::facts["macaddress_${public_interface}"]
network_config { $external_device:
ensure => 'present',
family => 'inet',
method => 'manual',
options => {
'up' => "ifconfig ${external_device} 0.0.0.0 promisc up",
'down' => "ifconfig ${external_device} promisc down",
},
} ->
network_config { 'br-ex':
# Set public network if public_interface != $external_device1
if $public_gateway {
network_config { $public_interface:
ensure => 'present',
family => 'inet',
method => 'static',
ipaddress => $public_ipaddress,
netmask => $public_netmask,
} ->
network_config { 'lo':
ensure => 'present',
family => 'inet',
method => 'loopback',
onboot => 'true',
}->
vs_port { $external_device:
ensure => present,
bridge => 'br-ex',
require => Class['::neutron::agents::ml2::ovs'],
method => 'dhcp',
} ->
network_route { 'route_default':
ensure => 'present',
gateway => $external_gateway,
interface => 'br-ex',
gateway => $public_gateway,
interface => $public_interface,
netmask => '0.0.0.0',
network => 'default',
require => Package['ifupdown-extra']
} ->
exec { "set_br-ex_hwaddr":
command => "ovs-vsctl set bridge br-ex other-config:hwaddr=$public_macaddr",
path => "/usr/local/bin/:/bin/:/usr/bin:/sbin/:/usr/sbin/",
} ->
exec { "restart_external":
command => "ifconfig $external_device 0.0.0.0 promisc",
path => "/usr/local/bin/:/bin/:/sbin/:/usr/sbin/",
} ->
exec { "restart_br-ex":
command => "ifdown br-ex && ifup br-ex",
path => "/usr/local/bin/:/bin/:/sbin/:/usr/sbin/",
}
}
# Set loopback interface
network_config { 'lo':
ensure => 'present',
family => 'inet',
method => 'loopback',
onboot => 'true',
}
# Evaluate br-ex1, if present set it
if $::brex1_eval != 'br-ex1' {
## Store initial configuration from the public interface (assigned by DHCP) to restore on br-ex
$public_ipaddress1 = $::facts["ipaddress_${external_device1}"]
$public_netmask1 = $::facts["netmask_${external_device1}"]
$public_macaddr1 = $::facts["macaddress_${external_device1}"]
if $public_ipaddress1 {
network_config { $external_device1:
ensure => 'present',
family => 'inet',
method => 'manual',
options => {
'up' => "ifconfig ${external_device1} 0.0.0.0 promisc up",
'down' => "ifconfig ${external_device1} promisc down",
},
} ->
network_config { 'br-ex1':
ensure => 'present',
family => 'inet',
method => 'static',
ipaddress => $public_ipaddress1,
netmask => $public_netmask1,
} ->
vs_port { $external_device1:
ensure => present,
bridge => 'br-ex1',
require => Class['::neutron::agents::ml2::ovs'],
} ->
network_route { 'route_ext1':
ensure => 'present',
gateway => $external_gateway1,
interface => 'br-ex1',
netmask => '0.0.0.0',
network => 'default',
require => Package['ifupdown-extra']
} ->
exec { "set_br-ex1_hwaddr":
command => "ovs-vsctl set bridge br-ex1 other-config:hwaddr=$public_macaddr1",
path => "/usr/local/bin/:/bin/:/usr/bin:/sbin/:/usr/sbin/",
} ->
exec { "restart_external1":
command => "ifconfig $external_device1 0.0.0.0 promisc",
path => "/usr/local/bin/:/bin/:/sbin/:/usr/sbin/",
} ->
exec { "restart_br-ex1":
command => "ifdown br-ex1 && ifup br-ex1",
path => "/usr/local/bin/:/bin/:/sbin/:/usr/sbin/",
}
} else {
network_config { $external_device1:
ensure => 'present',
family => 'inet',
method => 'manual',
options => {
'up' => "ifconfig ${external_device1} 0.0.0.0 promisc up",
'down' => "ifconfig ${external_device1} promisc down",
},
} ->
vs_port { $external_device1:
ensure => present,
bridge => 'br-ex1',
require => Class['::neutron::agents::ml2::ovs'],
} ->
exec { "set_br-ex1_hwaddr":
command => "ovs-vsctl set bridge br-ex1 other-config:hwaddr=$public_macaddr1",
path => "/usr/local/bin/:/bin/:/usr/bin:/sbin/:/usr/sbin/",
}
}
}
if $external_device2 {
# notify { "external device2: $_external_device2 -- external network: $external_network2":
# loglevel => alert,
# }
# Evaluate br-ex2, if presetn set it
if $::brex2_eval != 'br-ex2' {
## Store initial configuration from the public interface (assigned by DHCP) to restore on br-ex
$public_ipaddress2 = $::facts["ipaddress_${external_device2}"]
$public_netmask2 = $::facts["netmask_${external_device2}"]
$public_macaddr2 = $::facts["macaddress_${external_device2}"]
network_config { $external_device2:
ensure => 'present',
family => 'inet',
method => 'manual',
options => {
'up' => "ifconfig ${external_device2} 0.0.0.0 promisc up",
'down' => "ifconfig ${external_device2} promisc down",
},
} ->
vs_port { $external_device2:
ensure => present,
bridge => 'br-ex2',
require => Class['::neutron::agents::ml2::ovs'],
} ->
exec { "set_br-ex2_hwaddr":
command => "ovs-vsctl set bridge br-ex2 other-config:hwaddr=$public_macaddr2",
path => "/usr/local/bin/:/bin/:/usr/bin:/sbin/:/usr/sbin/",
}
}
}
##Public/private network configuration for tenant - added
#class { '::iaas::setup::sharednetwork': }
}
Loading