From 8a1a3ce9d8e4e167846b884f83dfe4abfdb68c15 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Thu, 12 Jun 2014 14:53:56 -0600 Subject: [PATCH 01/12] corrected variable references to be ruby instance variables instead of ruby methods. fixes Puppet 3.x depreciation warnings. --- templates/ipconfig_Debian_bondslave.erb | 6 +++--- templates/ipconfig_Debian_dhcp.erb | 6 +++--- templates/ipconfig_Debian_manual.erb | 10 +++++----- templates/ipconfig_Debian_static.erb | 12 ++++++------ templates/ipconfig_RedHat_bondslave.erb | 2 +- templates/ipconfig_RedHat_dhcp.erb | 2 +- templates/ipconfig_RedHat_manual.erb | 2 +- templates/ipconfig_RedHat_static.erb | 6 +++--- templates/ipconfig_RedHat_static_down-script.erb | 4 ++-- templates/ipconfig_RedHat_static_up-script.erb | 4 ++-- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/templates/ipconfig_Debian_bondslave.erb b/templates/ipconfig_Debian_bondslave.erb index ed02a4e..080ac72 100644 --- a/templates/ipconfig_Debian_bondslave.erb +++ b/templates/ipconfig_Debian_bondslave.erb @@ -1,3 +1,3 @@ -auto <%= interface %> -iface <%= interface %> inet manual -bond-master <%= @bond_master %> \ No newline at end of file +auto <%= @interface %> +iface <%= @interface %> inet manual +bond-master <%= @bond_master %> diff --git a/templates/ipconfig_Debian_dhcp.erb b/templates/ipconfig_Debian_dhcp.erb index eb53a83..d5a297d 100644 --- a/templates/ipconfig_Debian_dhcp.erb +++ b/templates/ipconfig_Debian_dhcp.erb @@ -1,5 +1,5 @@ -auto <%= interface %> -iface <%= interface %> inet dhcp +auto <%= @interface %> +iface <%= @interface %> inet dhcp <% if @dhcp_hostname %>hostname <%= @dhcp_hostname %><% end %> <% if @vlan_mode %>vlan_raw_device <%= @vlan_dev %><% end %> <% if @mtu %>mtu <%= @mtu %><% end %> @@ -7,4 +7,4 @@ iface <%= interface %> inet dhcp bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/templates/ipconfig_Debian_manual.erb b/templates/ipconfig_Debian_manual.erb index 856f41d..ae4ceeb 100644 --- a/templates/ipconfig_Debian_manual.erb +++ b/templates/ipconfig_Debian_manual.erb @@ -1,11 +1,11 @@ -auto <%= interface %> -iface <%= interface %> inet manual +auto <%= @interface %> +iface <%= @interface %> inet manual <% if @vlan_mode %>vlan_raw_device <%= @vlan_dev %><% end %> -up ip l set <%= interface %> up -down ip l set <%= interface %> down +up ip l set <%= @interface %> up +down ip l set <%= @interface %> down <% if @mtu %>mtu <%= @mtu %><% end %> <% if @bond_mode %>slaves none bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/templates/ipconfig_Debian_static.erb b/templates/ipconfig_Debian_static.erb index 2b09637..2a7e5ce 100644 --- a/templates/ipconfig_Debian_static.erb +++ b/templates/ipconfig_Debian_static.erb @@ -1,8 +1,8 @@ -auto <%= interface %> -iface <%= interface %> inet static +auto <%= @interface %> +iface <%= @interface %> inet static <% if @vlan_mode %>vlan_raw_device <%= @vlan_dev %><% end %> -address <%= effective_ipaddr %> -netmask <%= effective_netmask %> +address <%= @effective_ipaddr %> +netmask <%= @effective_netmask %> <% if @def_gateway %>gateway <%= @def_gateway %><% end %> <% if @dns_nameservers_1 or @dns_nameservers_2 %>dns-nameservers <% if @dns_nameservers_1 %><%= @dns_nameservers_1 %><% end %> <% if @dns_nameservers_2 %><%= @dns_nameservers_2 %><% end %><% end %> <% if @dns_search_string %>dns-search <%= @dns_search_string %><% end %> @@ -14,6 +14,6 @@ bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> <% end %> <%- if @ipaddr_aliases -%><%- @ipaddr_aliases.each do |addr| -%> -post-up ip addr add <%= addr %> dev <%= interface %> -pre-down ip addr del <%= addr %> dev <%= interface %> +post-up ip addr add <%= addr %> dev <%= @interface %> +pre-down ip addr del <%= addr %> dev <%= @interface %> <%- end -%><%- end -%> diff --git a/templates/ipconfig_RedHat_bondslave.erb b/templates/ipconfig_RedHat_bondslave.erb index e511ba7..e68f800 100644 --- a/templates/ipconfig_RedHat_bondslave.erb +++ b/templates/ipconfig_RedHat_bondslave.erb @@ -1,4 +1,4 @@ -DEVICE=<%= interface %> +DEVICE=<%= @interface %> BOOTPROTO=none ONBOOT=yes USERCTL=no diff --git a/templates/ipconfig_RedHat_dhcp.erb b/templates/ipconfig_RedHat_dhcp.erb index 832416b..cad35f5 100644 --- a/templates/ipconfig_RedHat_dhcp.erb +++ b/templates/ipconfig_RedHat_dhcp.erb @@ -1,4 +1,4 @@ -DEVICE=<%= interface %> +DEVICE=<%= @interface %> BOOTPROTO=dhcp ONBOOT=yes USERCTL=no diff --git a/templates/ipconfig_RedHat_manual.erb b/templates/ipconfig_RedHat_manual.erb index 40e061a..2e06d28 100644 --- a/templates/ipconfig_RedHat_manual.erb +++ b/templates/ipconfig_RedHat_manual.erb @@ -1,4 +1,4 @@ -DEVICE=<%= interface %> +DEVICE=<%= @interface %> BOOTPROTO=none ONBOOT=yes USERCTL=no diff --git a/templates/ipconfig_RedHat_static.erb b/templates/ipconfig_RedHat_static.erb index d1e6b49..b7d5bc4 100644 --- a/templates/ipconfig_RedHat_static.erb +++ b/templates/ipconfig_RedHat_static.erb @@ -1,6 +1,6 @@ -DEVICE=<%= interface %> -IPADDR=<%= effective_ipaddr %> -NETMASK=<%= effective_netmask %> +DEVICE=<%= @interface %> +IPADDR=<%= @effective_ipaddr %> +NETMASK=<%= @effective_netmask %> BOOTPROTO=none ONBOOT=yes USERCTL=no diff --git a/templates/ipconfig_RedHat_static_down-script.erb b/templates/ipconfig_RedHat_static_down-script.erb index d19494e..a77e3bc 100644 --- a/templates/ipconfig_RedHat_static_down-script.erb +++ b/templates/ipconfig_RedHat_static_down-script.erb @@ -1,7 +1,7 @@ #!/bin/sh <%- if @ipaddr_aliases -%> <%- @ipaddr_aliases.each do |addr| -%> -ip addr del <%= addr %> dev <%= interface %> +ip addr del <%= addr %> dev <%= @interface %> <%- end -%> <%- end -%> -true \ No newline at end of file +true diff --git a/templates/ipconfig_RedHat_static_up-script.erb b/templates/ipconfig_RedHat_static_up-script.erb index 66e8628..bf623ca 100644 --- a/templates/ipconfig_RedHat_static_up-script.erb +++ b/templates/ipconfig_RedHat_static_up-script.erb @@ -1,7 +1,7 @@ #!/bin/sh <%- if @ipaddr_aliases -%> <%- @ipaddr_aliases.each do |addr| -%> -ip addr add <%= addr %> dev <%= interface %> +ip addr add <%= addr %> dev <%= @interface %> <%- end -%> <%- end -%> -true \ No newline at end of file +true From fccbcf14f6c8a13c605a7232f8495998cdcd3fb7 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Thu, 12 Jun 2014 15:50:03 -0600 Subject: [PATCH 02/12] support configuring bridge interfaces on EL-based distros --- manifests/l3/ifconfig.pp | 15 +++++++++++++++ templates/ipconfig_RedHat_dhcp.erb | 2 ++ templates/ipconfig_RedHat_manual.erb | 2 ++ templates/ipconfig_RedHat_static.erb | 2 ++ 4 files changed, 21 insertions(+) diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index b78ee1b..6e658c3 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -69,6 +69,10 @@ # [*check_by_ping_timeout*] # Timeout for check_by_ping # +# [*bridge*] +# Bridge interface that this interface should be attached to +# Only supported on EL-based distros +# # # If you configure 802.1q vlan interfaces then you must declare relationships # between them in site.pp. @@ -93,6 +97,7 @@ $ifname_order_prefix = false, $check_by_ping = 'gateway', $check_by_ping_timeout = 120, + $bridge = false, #todo: label => "XXX", # -- "ip addr add..... label XXX" ){ include ::l23network::params @@ -225,6 +230,16 @@ } } + # Interface type: + $iftype = $interface ? { + /^br\d+/ => 'Bridge', + default => false, + } + + if $iftype == 'Bridge' and $::osfamily ~! /(?i)redhat/ { + fail("bridge parameter unsupported on ${::osfamily}/${::operatingsystem}") + } + # Specify interface file name prefix if $ifname_order_prefix { $interface_file= "${if_files_dir}/ifcfg-${ifname_order_prefix}-${interface}" diff --git a/templates/ipconfig_RedHat_dhcp.erb b/templates/ipconfig_RedHat_dhcp.erb index 832416b..7de8b4b 100644 --- a/templates/ipconfig_RedHat_dhcp.erb +++ b/templates/ipconfig_RedHat_dhcp.erb @@ -1,4 +1,5 @@ DEVICE=<%= interface %> +<% if @iftype %>TYPE=<%= @iftype %><% end %> BOOTPROTO=dhcp ONBOOT=yes USERCTL=no @@ -8,3 +9,4 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> +<% if @bridge %>BRIDGE=<%= @bridge %><% end %> diff --git a/templates/ipconfig_RedHat_manual.erb b/templates/ipconfig_RedHat_manual.erb index 40e061a..44dee76 100644 --- a/templates/ipconfig_RedHat_manual.erb +++ b/templates/ipconfig_RedHat_manual.erb @@ -1,4 +1,5 @@ DEVICE=<%= interface %> +<% if @iftype %>TYPE=<%= @iftype %><% end %> BOOTPROTO=none ONBOOT=yes USERCTL=no @@ -7,3 +8,4 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> +<% if @bridge %>BRIDGE=<%= @bridge %><% end %> diff --git a/templates/ipconfig_RedHat_static.erb b/templates/ipconfig_RedHat_static.erb index d1e6b49..d3fcefd 100644 --- a/templates/ipconfig_RedHat_static.erb +++ b/templates/ipconfig_RedHat_static.erb @@ -1,4 +1,5 @@ DEVICE=<%= interface %> +<% if @iftype %>TYPE=<%= @iftype %><% end %> IPADDR=<%= effective_ipaddr %> NETMASK=<%= effective_netmask %> BOOTPROTO=none @@ -13,3 +14,4 @@ PHYSDEV=<%= @vlan_dev %><% end %> <% if @dns_search_string %>SEARCH=<%= @dns_search_string %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> +<% if @bridge %>BRIDGE=<%= @bridge %><% end %> From 896b1c04606ab9f75ad6f99452192fa145707f05 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Thu, 12 Jun 2014 16:08:20 -0600 Subject: [PATCH 03/12] bridge support under OVS; corrected openvsiwtch-kmod package name for EL distros --- manifests/l3/ifconfig.pp | 10 ++++++++-- manifests/params.pp | 4 ++-- templates/ipconfig_RedHat_bondslave.erb | 1 + templates/ipconfig_RedHat_dhcp.erb | 3 ++- templates/ipconfig_RedHat_manual.erb | 3 ++- templates/ipconfig_RedHat_static.erb | 3 ++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index 6e658c3..80c1e6d 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -232,8 +232,14 @@ # Interface type: $iftype = $interface ? { - /^br\d+/ => 'Bridge', - default => false, + /^br\d+/ => $::l23network::use_ovs ? { true => 'OVSBridge', default => 'Bridge' }, + default => $::l23network::use_ovs ? { true => 'OVSPort', default => false } + } + + # Device type: + $devtype = $::l23network::use_ovs ? { + true => 'ovs', + default => false } if $iftype == 'Bridge' and $::osfamily ~! /(?i)redhat/ { diff --git a/manifests/params.pp b/manifests/params.pp index d9e26df..6b78d60 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -10,8 +10,8 @@ } /(?i)redhat/: { $ovs_service_name = 'openvswitch' #'ovs-vswitchd' - $ovs_status_cmd = '/etc/init.d/openvswitch status' - $ovs_packages = ['kmod-openvswitch', 'openvswitch'] + $ovs_status_cmd = '/etc/init.d/openvswitch status | grep -q "is running"' + $ovs_packages = ['openvswitch-kmod', 'openvswitch'] $lnx_vlan_tools = 'vconfig' $lnx_bond_tools = undef $lnx_ethernet_tools = 'ethtool' diff --git a/templates/ipconfig_RedHat_bondslave.erb b/templates/ipconfig_RedHat_bondslave.erb index e511ba7..7032e0a 100644 --- a/templates/ipconfig_RedHat_bondslave.erb +++ b/templates/ipconfig_RedHat_bondslave.erb @@ -1,4 +1,5 @@ DEVICE=<%= interface %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> BOOTPROTO=none ONBOOT=yes USERCTL=no diff --git a/templates/ipconfig_RedHat_dhcp.erb b/templates/ipconfig_RedHat_dhcp.erb index 7de8b4b..cd589fa 100644 --- a/templates/ipconfig_RedHat_dhcp.erb +++ b/templates/ipconfig_RedHat_dhcp.erb @@ -1,5 +1,6 @@ DEVICE=<%= interface %> <% if @iftype %>TYPE=<%= @iftype %><% end %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> BOOTPROTO=dhcp ONBOOT=yes USERCTL=no @@ -9,4 +10,4 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> -<% if @bridge %>BRIDGE=<%= @bridge %><% end %> +<% if @bridge %><% if scope.lookupvar('::l23network::use_ovs') %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> diff --git a/templates/ipconfig_RedHat_manual.erb b/templates/ipconfig_RedHat_manual.erb index 44dee76..f23a1bc 100644 --- a/templates/ipconfig_RedHat_manual.erb +++ b/templates/ipconfig_RedHat_manual.erb @@ -1,5 +1,6 @@ DEVICE=<%= interface %> <% if @iftype %>TYPE=<%= @iftype %><% end %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> BOOTPROTO=none ONBOOT=yes USERCTL=no @@ -8,4 +9,4 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> -<% if @bridge %>BRIDGE=<%= @bridge %><% end %> +<% if @bridge %><% if scope.lookupvar('::l23network::use_ovs') %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> diff --git a/templates/ipconfig_RedHat_static.erb b/templates/ipconfig_RedHat_static.erb index d3fcefd..38a985c 100644 --- a/templates/ipconfig_RedHat_static.erb +++ b/templates/ipconfig_RedHat_static.erb @@ -1,5 +1,6 @@ DEVICE=<%= interface %> <% if @iftype %>TYPE=<%= @iftype %><% end %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> IPADDR=<%= effective_ipaddr %> NETMASK=<%= effective_netmask %> BOOTPROTO=none @@ -14,4 +15,4 @@ PHYSDEV=<%= @vlan_dev %><% end %> <% if @dns_search_string %>SEARCH=<%= @dns_search_string %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> -<% if @bridge %>BRIDGE=<%= @bridge %><% end %> +<% if @bridge %><% if scope.lookupvar('::l23network::use_ovs') %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> From d3d1f6e5c8d2f71ffa2d89dd8e387915d9b9e210 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Thu, 12 Jun 2014 16:39:52 -0600 Subject: [PATCH 04/12] support for configuring static routes with interface --- manifests/l3/ifconfig.pp | 15 +++++++++++++++ templates/ipconfig_Debian_bondslave.erb | 6 +++++- templates/ipconfig_Debian_dhcp.erb | 5 ++++- templates/ipconfig_Debian_manual.erb | 5 ++++- templates/ipconfig_Debian_static.erb | 3 +++ templates/route_RedHat.erb | 3 +++ 6 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 templates/route_RedHat.erb diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index b78ee1b..6f0c5a5 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -69,6 +69,10 @@ # [*check_by_ping_timeout*] # Timeout for check_by_ping # +# [*routes] +# Static routes to be added for this interface. Format: +# [-net|-host] / [gw ] +# # # If you configure 802.1q vlan interfaces then you must declare relationships # between them in site.pp. @@ -93,6 +97,7 @@ $ifname_order_prefix = false, $check_by_ping = 'gateway', $check_by_ping_timeout = 120, + $routes = undef, #todo: label => "XXX", # -- "ip addr add..... label XXX" ){ include ::l23network::params @@ -287,6 +292,16 @@ File <| title == $interface_file |> } + if $routes and $::osfamily =~ /(?i)redhat/: { + file { "/etc/sysconfig/network-scripts/route-${interface}": + ensure => present, + content => template("l23network/route_RedHat.erb"), + owner => "root", + group => "root", + mode => "0644", + notify => L3_if_downup["${interface}"], + } + notify {"ifconfig_${interface}": message=>"Interface:${interface} IP:${effective_ipaddr}/${effective_netmask}", withpath=>false} -> l3_if_downup {"$interface": check_by_ping => $check_by_ping, diff --git a/templates/ipconfig_Debian_bondslave.erb b/templates/ipconfig_Debian_bondslave.erb index ed02a4e..c8436eb 100644 --- a/templates/ipconfig_Debian_bondslave.erb +++ b/templates/ipconfig_Debian_bondslave.erb @@ -1,3 +1,7 @@ auto <%= interface %> iface <%= interface %> inet manual -bond-master <%= @bond_master %> \ No newline at end of file +bond-master <%= @bond_master %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> + diff --git a/templates/ipconfig_Debian_dhcp.erb b/templates/ipconfig_Debian_dhcp.erb index eb53a83..5dbb357 100644 --- a/templates/ipconfig_Debian_dhcp.erb +++ b/templates/ipconfig_Debian_dhcp.erb @@ -7,4 +7,7 @@ iface <%= interface %> inet dhcp bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> diff --git a/templates/ipconfig_Debian_manual.erb b/templates/ipconfig_Debian_manual.erb index 856f41d..35b5b60 100644 --- a/templates/ipconfig_Debian_manual.erb +++ b/templates/ipconfig_Debian_manual.erb @@ -8,4 +8,7 @@ down ip l set <%= interface %> down bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> diff --git a/templates/ipconfig_Debian_static.erb b/templates/ipconfig_Debian_static.erb index 2b09637..994e5b1 100644 --- a/templates/ipconfig_Debian_static.erb +++ b/templates/ipconfig_Debian_static.erb @@ -17,3 +17,6 @@ bond-lacp-rate <%= @bond_lacp_rate %><% end %> post-up ip addr add <%= addr %> dev <%= interface %> pre-down ip addr del <%= addr %> dev <%= interface %> <%- end -%><%- end -%> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> diff --git a/templates/route_RedHat.erb b/templates/route_RedHat.erb new file mode 100644 index 0000000..9bafdf5 --- /dev/null +++ b/templates/route_RedHat.erb @@ -0,0 +1,3 @@ +<% @routes.each do |route| -%> +<%= route %> +<% end -%> From 21414bd967854de37096f1a86a07744266cc7a5e Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Thu, 12 Jun 2014 16:39:52 -0600 Subject: [PATCH 05/12] support for configuring static routes with interface --- manifests/l3/ifconfig.pp | 15 +++++++++++++++ templates/ipconfig_Debian_bondslave.erb | 5 ++++- templates/ipconfig_Debian_dhcp.erb | 5 ++++- templates/ipconfig_Debian_manual.erb | 5 ++++- templates/ipconfig_Debian_static.erb | 3 +++ templates/route_RedHat.erb | 3 +++ 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 templates/route_RedHat.erb diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index b78ee1b..6f0c5a5 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -69,6 +69,10 @@ # [*check_by_ping_timeout*] # Timeout for check_by_ping # +# [*routes] +# Static routes to be added for this interface. Format: +# [-net|-host] / [gw ] +# # # If you configure 802.1q vlan interfaces then you must declare relationships # between them in site.pp. @@ -93,6 +97,7 @@ $ifname_order_prefix = false, $check_by_ping = 'gateway', $check_by_ping_timeout = 120, + $routes = undef, #todo: label => "XXX", # -- "ip addr add..... label XXX" ){ include ::l23network::params @@ -287,6 +292,16 @@ File <| title == $interface_file |> } + if $routes and $::osfamily =~ /(?i)redhat/: { + file { "/etc/sysconfig/network-scripts/route-${interface}": + ensure => present, + content => template("l23network/route_RedHat.erb"), + owner => "root", + group => "root", + mode => "0644", + notify => L3_if_downup["${interface}"], + } + notify {"ifconfig_${interface}": message=>"Interface:${interface} IP:${effective_ipaddr}/${effective_netmask}", withpath=>false} -> l3_if_downup {"$interface": check_by_ping => $check_by_ping, diff --git a/templates/ipconfig_Debian_bondslave.erb b/templates/ipconfig_Debian_bondslave.erb index ed02a4e..926e646 100644 --- a/templates/ipconfig_Debian_bondslave.erb +++ b/templates/ipconfig_Debian_bondslave.erb @@ -1,3 +1,6 @@ auto <%= interface %> iface <%= interface %> inet manual -bond-master <%= @bond_master %> \ No newline at end of file +bond-master <%= @bond_master %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> diff --git a/templates/ipconfig_Debian_dhcp.erb b/templates/ipconfig_Debian_dhcp.erb index eb53a83..5dbb357 100644 --- a/templates/ipconfig_Debian_dhcp.erb +++ b/templates/ipconfig_Debian_dhcp.erb @@ -7,4 +7,7 @@ iface <%= interface %> inet dhcp bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> diff --git a/templates/ipconfig_Debian_manual.erb b/templates/ipconfig_Debian_manual.erb index 856f41d..35b5b60 100644 --- a/templates/ipconfig_Debian_manual.erb +++ b/templates/ipconfig_Debian_manual.erb @@ -8,4 +8,7 @@ down ip l set <%= interface %> down bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> diff --git a/templates/ipconfig_Debian_static.erb b/templates/ipconfig_Debian_static.erb index 2b09637..994e5b1 100644 --- a/templates/ipconfig_Debian_static.erb +++ b/templates/ipconfig_Debian_static.erb @@ -17,3 +17,6 @@ bond-lacp-rate <%= @bond_lacp_rate %><% end %> post-up ip addr add <%= addr %> dev <%= interface %> pre-down ip addr del <%= addr %> dev <%= interface %> <%- end -%><%- end -%> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> diff --git a/templates/route_RedHat.erb b/templates/route_RedHat.erb new file mode 100644 index 0000000..9bafdf5 --- /dev/null +++ b/templates/route_RedHat.erb @@ -0,0 +1,3 @@ +<% @routes.each do |route| -%> +<%= route %> +<% end -%> From 3d9edb89e08f591ac5e39a7c58cfa3101ae4e7f9 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Thu, 12 Jun 2014 17:14:10 -0600 Subject: [PATCH 06/12] OVS bonding and advanced OVS config support --- manifests/l3/ifconfig.pp | 33 +++++++++++++++++++++++-- templates/ipconfig_Debian_bondslave.erb | 5 +++- templates/ipconfig_Debian_dhcp.erb | 6 ++++- templates/ipconfig_Debian_manual.erb | 6 ++++- templates/ipconfig_Debian_static.erb | 4 +++ templates/ipconfig_RedHat_bondslave.erb | 2 ++ templates/ipconfig_RedHat_dhcp.erb | 3 +++ templates/ipconfig_RedHat_manual.erb | 4 +++ templates/ipconfig_RedHat_static.erb | 4 +++ 9 files changed, 62 insertions(+), 5 deletions(-) diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index b78ee1b..f649eb4 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -34,6 +34,11 @@ # [*bond_lacp_rate*] # lacp MII rate # +# [*bond_ifaces*] +# Array, or space-separated list of interfaces that should be on this +# bond interface. Only used if OVS enabled (global ::l23network::use_ovs +# or use_ovs_override are set to true.) +# # [*ifname_order_prefix*] # Sets the interface startup order # @@ -69,6 +74,17 @@ # [*check_by_ping_timeout*] # Timeout for check_by_ping # +# [*use_ovs_override*] +# Override the global ::l23network::use_ovs setting for this interface. (For +# Linux/OVS hybrid network setups, or situations where ::l23network::use_ovs +# is set by a higher level Puppet class.) +# +# [*ovs_extra*] +# Extra OVS configuration to be included in the interface file OVS_EXTRA. +# +# [*ovs_options*] +# Extra OVS configuration to be included in the interface file OVS_OPTIONS. +# # # If you configure 802.1q vlan interfaces then you must declare relationships # between them in site.pp. @@ -84,6 +100,7 @@ $bond_mode = undef, $bond_miimon = 100, $bond_lacp_rate = 1, + $bond_ifaces = undef, $mtu = undef, $dns_nameservers = undef, $dns_search = undef, @@ -93,6 +110,9 @@ $ifname_order_prefix = false, $check_by_ping = 'gateway', $check_by_ping_timeout = 120, + $use_ovs_override = undef, + $ovs_extra = undef, + $ovs_options = undef, #todo: label => "XXX", # -- "ip addr add..... label XXX" ){ include ::l23network::params @@ -107,6 +127,15 @@ 'balance-alb' ] + # Determine if we're using OVS for this interface + $real_use_ovs = $use_ovs_override ? { undef => $::l23network::use_ovs, false => $::l23network::use_ovs, default => $use_ovs_override } + + # Ignore bond slave interfaces if not using OVS + $real_bond_ifaces = $interface ? { + /^bond/ => $real_use_ovs ? { true => $bond_ifaces, default => undef }, + default => undef + } + # setup configure method for inteface if $bond_master { $method = 'bondslave' @@ -212,10 +241,10 @@ $vlan_dev = $1 } /^(bond\d+)/: { - if ! $bond_mode { + if ! $real_use_ovs and ! $bond_mode { fail("To configure the interface bonding you must the bond_mode parameter is required and must be between 0..6.") } - if $bond_mode <0 or $bond_mode>6 { + if ! $real_use_ovs and ($bond_mode <0 or $bond_mode>6) { fail("For interface bonding the bond_mode must be between 0..6, not '${bond_mode}'.") } $vlan_mode = undef diff --git a/templates/ipconfig_Debian_bondslave.erb b/templates/ipconfig_Debian_bondslave.erb index ed02a4e..f4a52a2 100644 --- a/templates/ipconfig_Debian_bondslave.erb +++ b/templates/ipconfig_Debian_bondslave.erb @@ -1,3 +1,6 @@ auto <%= interface %> iface <%= interface %> inet manual -bond-master <%= @bond_master %> \ No newline at end of file +bond-master <%= @bond_master %> +<% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> +<% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> + diff --git a/templates/ipconfig_Debian_dhcp.erb b/templates/ipconfig_Debian_dhcp.erb index eb53a83..a37c8d8 100644 --- a/templates/ipconfig_Debian_dhcp.erb +++ b/templates/ipconfig_Debian_dhcp.erb @@ -7,4 +7,8 @@ iface <%= interface %> inet dhcp bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% if @real_bond_ifaces %>ovs_bonds <%= @real_bond_ifaces %><% end %> +<% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> +<% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> + diff --git a/templates/ipconfig_Debian_manual.erb b/templates/ipconfig_Debian_manual.erb index 856f41d..7d751e6 100644 --- a/templates/ipconfig_Debian_manual.erb +++ b/templates/ipconfig_Debian_manual.erb @@ -8,4 +8,8 @@ down ip l set <%= interface %> down bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% if @real_bond_ifaces %>ovs_bonds <%= @real_bond_ifaces %><% end %> +<% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> +<% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> + diff --git a/templates/ipconfig_Debian_static.erb b/templates/ipconfig_Debian_static.erb index 2b09637..096ef15 100644 --- a/templates/ipconfig_Debian_static.erb +++ b/templates/ipconfig_Debian_static.erb @@ -13,7 +13,11 @@ bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> <% end %> +<% if @real_bond_ifaces %>ovs_bonds <%= @real_bond_ifaces %><% end %> <%- if @ipaddr_aliases -%><%- @ipaddr_aliases.each do |addr| -%> post-up ip addr add <%= addr %> dev <%= interface %> pre-down ip addr del <%= addr %> dev <%= interface %> <%- end -%><%- end -%> +<% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> +<% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> + diff --git a/templates/ipconfig_RedHat_bondslave.erb b/templates/ipconfig_RedHat_bondslave.erb index e511ba7..dd27d6c 100644 --- a/templates/ipconfig_RedHat_bondslave.erb +++ b/templates/ipconfig_RedHat_bondslave.erb @@ -4,3 +4,5 @@ ONBOOT=yes USERCTL=no MASTER=<%= @bond_master %> SLAVE=yes +<% if @ovs_extra %>OVS_EXTRA="<%= @ovs_extra %>"<% end %> +<% if @ovs_options %>OVS_OPTIONS="<%= @ovs_options %>"<% end %> diff --git a/templates/ipconfig_RedHat_dhcp.erb b/templates/ipconfig_RedHat_dhcp.erb index 832416b..8ddfbf8 100644 --- a/templates/ipconfig_RedHat_dhcp.erb +++ b/templates/ipconfig_RedHat_dhcp.erb @@ -8,3 +8,6 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> +<% if @real_bond_ifaces %>BOND_IFACES="<%= @real_bond_ifaces %>"<% end %> +<% if @ovs_extra %>OVS_EXTRA="<%= @ovs_extra %>"<% end %> +<% if @ovs_options %>OVS_OPTIONS="<%= @ovs_options %>"<% end %> diff --git a/templates/ipconfig_RedHat_manual.erb b/templates/ipconfig_RedHat_manual.erb index 40e061a..ad49775 100644 --- a/templates/ipconfig_RedHat_manual.erb +++ b/templates/ipconfig_RedHat_manual.erb @@ -7,3 +7,7 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> +<% if @real_bond_ifaces %>BOND_IFACES="<%= @real_bond_ifaces %>"<% end %> +<% if @ovs_extra %>OVS_EXTRA="<%= @ovs_extra %>"<% end %> +<% if @ovs_options %>OVS_OPTIONS="<%= @ovs_options %>"<% end %> + diff --git a/templates/ipconfig_RedHat_static.erb b/templates/ipconfig_RedHat_static.erb index d1e6b49..4681254 100644 --- a/templates/ipconfig_RedHat_static.erb +++ b/templates/ipconfig_RedHat_static.erb @@ -13,3 +13,7 @@ PHYSDEV=<%= @vlan_dev %><% end %> <% if @dns_search_string %>SEARCH=<%= @dns_search_string %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> +<% if @real_bond_ifaces %>BOND_IFACES="<%= @real_bond_ifaces %>"<% end %> +<% if @ovs_extra %>OVS_EXTRA="<%= @ovs_extra %>"<% end %> +<% if @ovs_options %>OVS_OPTIONS="<%= @ovs_options %>"<% end %> + From 5a5f2b41b58418f40ed032e1dc2cecc8e15cf47a Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Fri, 13 Jun 2014 09:16:21 -0600 Subject: [PATCH 07/12] added type_override parameter --- manifests/l3/ifconfig.pp | 21 ++++++++++++++++----- templates/ipconfig_RedHat_dhcp.erb | 2 +- templates/ipconfig_RedHat_manual.erb | 2 +- templates/ipconfig_RedHat_static.erb | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index 2175869..9fd2659 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -93,6 +93,11 @@ # [*ovs_options*] # Extra OVS configuration to be included in the interface file OVS_OPTIONS. # +# [*type_override*] +# Override the automatically detected interface type value. For configuring +# interfaces like mgmt0, whose names to not necessarily conform to the +# regular interface naming conventions. +# # # If you configure 802.1q vlan interfaces then you must declare relationships # between them in site.pp. @@ -123,6 +128,7 @@ $use_ovs_override = undef, $ovs_extra = undef, $ovs_options = undef, + $type_override = undef, #todo: label => "XXX", # -- "ip addr add..... label XXX" ){ include ::l23network::params @@ -265,18 +271,23 @@ } } - # Interface type: - $iftype = $interface ? { - /^br\d+/ => $::l23network::use_ovs ? { true => 'OVSBridge', default => 'Bridge' }, - default => $::l23network::use_ovs ? { true => 'OVSPort', default => false } + # Interface type (taking into account $type_override setting): + $iftype = $type_override ? { + default => $type_override, + undef => $interface ? { + /^br[-\d]+/ => $real_use_ovs ? { true => 'OVSBridge', default => 'Bridge' }, + /^bond\d+/ => $real_use_ovs ? { true => 'OVSBond', default => 'Bonding' }, + default => $real_use_ovs ? { true => 'OVSPort', default => false } + } } # Device type: - $devtype = $::l23network::use_ovs ? { + $devtype = $real_use_ovs ? { true => 'ovs', default => false } + if $iftype == 'Bridge' and $::osfamily ~! /(?i)redhat/ { fail("bridge parameter unsupported on ${::osfamily}/${::operatingsystem}") } diff --git a/templates/ipconfig_RedHat_dhcp.erb b/templates/ipconfig_RedHat_dhcp.erb index 46a8037..f4ce745 100644 --- a/templates/ipconfig_RedHat_dhcp.erb +++ b/templates/ipconfig_RedHat_dhcp.erb @@ -10,7 +10,7 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> -<% if @bridge %><% if scope.lookupvar('::l23network::use_ovs') %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> +<% if @bridge %><% if @real_use_ovs %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> <% if @real_bond_ifaces %>BOND_IFACES="<%= @real_bond_ifaces %>"<% end %> <% if @ovs_extra %>OVS_EXTRA="<%= @ovs_extra %>"<% end %> <% if @ovs_options %>OVS_OPTIONS="<%= @ovs_options %>"<% end %> diff --git a/templates/ipconfig_RedHat_manual.erb b/templates/ipconfig_RedHat_manual.erb index e3f5a1e..2bb4d29 100644 --- a/templates/ipconfig_RedHat_manual.erb +++ b/templates/ipconfig_RedHat_manual.erb @@ -9,7 +9,7 @@ USERCTL=no PHYSDEV=<%= @vlan_dev %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> -<% if @bridge %><% if scope.lookupvar('::l23network::use_ovs') %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> +<% if @bridge %><% if @real_use_ovs %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> <% if @real_bond_ifaces %>BOND_IFACES="<%= @real_bond_ifaces %>"<% end %> <% if @ovs_extra %>OVS_EXTRA="<%= @ovs_extra %>"<% end %> <% if @ovs_options %>OVS_OPTIONS="<%= @ovs_options %>"<% end %> diff --git a/templates/ipconfig_RedHat_static.erb b/templates/ipconfig_RedHat_static.erb index 3c76e66..0721516 100644 --- a/templates/ipconfig_RedHat_static.erb +++ b/templates/ipconfig_RedHat_static.erb @@ -15,7 +15,7 @@ PHYSDEV=<%= @vlan_dev %><% end %> <% if @dns_search_string %>SEARCH=<%= @dns_search_string %><% end %> <% if @mtu %>MTU=<%= @mtu %><% end %> <% if @bond_mode %>BONDING_OPTS="mode=<%= @bond_mode %><% if @bond_miimon %> miimon=<%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate=<%= @bond_lacp_rate %><% end %>"<% end %> -<% if @bridge %><% if scope.lookupvar('::l23network::use_ovs') %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> +<% if @bridge %><% if @real_use_ovs %>OVS_BRIDGE=<%= @bridge %><% else %>BRIDGE=<%= @bridge %><% end %><% end %> <% if @real_bond_ifaces %>BOND_IFACES="<%= @real_bond_ifaces %>"<% end %> <% if @ovs_extra %>OVS_EXTRA="<%= @ovs_extra %>"<% end %> <% if @ovs_options %>OVS_OPTIONS="<%= @ovs_options %>"<% end %> From 36eb038f4ae897fe6eb70dc3e5d2b2fa5ed5f065 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Fri, 13 Jun 2014 09:21:22 -0600 Subject: [PATCH 08/12] proper config for OVS bridges under Debian/Ubuntu --- templates/ipconfig_Debian_dhcp.erb | 4 +++- templates/ipconfig_Debian_manual.erb | 4 +++- templates/ipconfig_Debian_static.erb | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/templates/ipconfig_Debian_dhcp.erb b/templates/ipconfig_Debian_dhcp.erb index eb53a83..35a38a5 100644 --- a/templates/ipconfig_Debian_dhcp.erb +++ b/templates/ipconfig_Debian_dhcp.erb @@ -1,5 +1,6 @@ auto <%= interface %> iface <%= interface %> inet dhcp +<% if @devtype %>ovs_type <%= @devtype %><% end %> <% if @dhcp_hostname %>hostname <%= @dhcp_hostname %><% end %> <% if @vlan_mode %>vlan_raw_device <%= @vlan_dev %><% end %> <% if @mtu %>mtu <%= @mtu %><% end %> @@ -7,4 +8,5 @@ iface <%= interface %> inet dhcp bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% if scope.lookupvar('::l23network::use_ovs') %>ovs_bridge <%= @bridge %><% end %> diff --git a/templates/ipconfig_Debian_manual.erb b/templates/ipconfig_Debian_manual.erb index 856f41d..3f52f9d 100644 --- a/templates/ipconfig_Debian_manual.erb +++ b/templates/ipconfig_Debian_manual.erb @@ -1,5 +1,6 @@ auto <%= interface %> iface <%= interface %> inet manual +<% if @devtype %>ovs_type <%= @devtype %><% end %> <% if @vlan_mode %>vlan_raw_device <%= @vlan_dev %><% end %> up ip l set <%= interface %> up down ip l set <%= interface %> down @@ -8,4 +9,5 @@ down ip l set <%= interface %> down bond-mode <%= @bond_mode %><% if @bond_miimon %> bond-miimon <%= @bond_miimon %><% end %><% if @bond_lacp_rate %> bond-lacp-rate <%= @bond_lacp_rate %><% end %> -<% end %> \ No newline at end of file +<% end %> +<% if scope.lookupvar('::l23network::use_ovs') %>ovs_bridge <%= @bridge %><% end %> diff --git a/templates/ipconfig_Debian_static.erb b/templates/ipconfig_Debian_static.erb index 2b09637..d62df47 100644 --- a/templates/ipconfig_Debian_static.erb +++ b/templates/ipconfig_Debian_static.erb @@ -1,5 +1,6 @@ auto <%= interface %> iface <%= interface %> inet static +<% if @devtype %>ovs_type <%= @devtype %><% end %> <% if @vlan_mode %>vlan_raw_device <%= @vlan_dev %><% end %> address <%= effective_ipaddr %> netmask <%= effective_netmask %> @@ -17,3 +18,4 @@ bond-lacp-rate <%= @bond_lacp_rate %><% end %> post-up ip addr add <%= addr %> dev <%= interface %> pre-down ip addr del <%= addr %> dev <%= interface %> <%- end -%><%- end -%> +<% if scope.lookupvar('::l23network::use_ovs') %>ovs_bridge <%= @bridge %><% end %> From 424dab542025b86be63e697e6548375ebd25e0f1 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Fri, 13 Jun 2014 09:27:37 -0600 Subject: [PATCH 09/12] proper checking for use_ovs in Debian templates --- templates/ipconfig_Debian_dhcp.erb | 2 +- templates/ipconfig_Debian_manual.erb | 2 +- templates/ipconfig_Debian_static.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/ipconfig_Debian_dhcp.erb b/templates/ipconfig_Debian_dhcp.erb index e9f87fd..85db1af 100644 --- a/templates/ipconfig_Debian_dhcp.erb +++ b/templates/ipconfig_Debian_dhcp.erb @@ -15,4 +15,4 @@ up route add <%= route %> dev <%= @interface %> <% if @real_bond_ifaces %>ovs_bonds <%= @real_bond_ifaces %><% end %> <% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> <% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> -<% if scope.lookupvar('::l23network::use_ovs') %>ovs_bridge <%= @bridge %><% end %> +<% if @real_use_ovs %>ovs_bridge <%= @bridge %><% end %> diff --git a/templates/ipconfig_Debian_manual.erb b/templates/ipconfig_Debian_manual.erb index 2f9c4be..960024f 100644 --- a/templates/ipconfig_Debian_manual.erb +++ b/templates/ipconfig_Debian_manual.erb @@ -16,4 +16,4 @@ up route add <%= route %> dev <%= @interface %> <% if @real_bond_ifaces %>ovs_bonds <%= @real_bond_ifaces %><% end %> <% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> <% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> -<% if scope.lookupvar('::l23network::use_ovs') %>ovs_bridge <%= @bridge %><% end %> +<% if @real_use_ovs %>ovs_bridge <%= @bridge %><% end %> diff --git a/templates/ipconfig_Debian_static.erb b/templates/ipconfig_Debian_static.erb index 6b952c8..ae206b7 100644 --- a/templates/ipconfig_Debian_static.erb +++ b/templates/ipconfig_Debian_static.erb @@ -24,4 +24,4 @@ up route add <%= route %> dev <%= @interface %> <% end -%> <% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> <% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> -<% if scope.lookupvar('::l23network::use_ovs') %>ovs_bridge <%= @bridge %><% end %> +<% if @real_use_ovs %>ovs_bridge <%= @bridge %><% end %> From a912bcd531a0a5af19b5988724f2d0377e0eee35 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Fri, 13 Jun 2014 09:35:41 -0600 Subject: [PATCH 10/12] typo on !~ operator --- manifests/l3/ifconfig.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index 80c1e6d..b441551 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -242,7 +242,7 @@ default => false } - if $iftype == 'Bridge' and $::osfamily ~! /(?i)redhat/ { + if $iftype == 'Bridge' and $::osfamily !~ /(?i)redhat/ { fail("bridge parameter unsupported on ${::osfamily}/${::operatingsystem}") } From 85d4fb2d613b01967eb7cd18dab8b8845a8b3865 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Fri, 13 Jun 2014 10:00:18 -0600 Subject: [PATCH 11/12] typo and missing } --- manifests/l3/ifconfig.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index 6f0c5a5..f3839fe 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -292,7 +292,7 @@ File <| title == $interface_file |> } - if $routes and $::osfamily =~ /(?i)redhat/: { + if $routes and $::osfamily =~ /(?i)redhat/ { file { "/etc/sysconfig/network-scripts/route-${interface}": ensure => present, content => template("l23network/route_RedHat.erb"), @@ -300,6 +300,7 @@ group => "root", mode => "0644", notify => L3_if_downup["${interface}"], + } } notify {"ifconfig_${interface}": message=>"Interface:${interface} IP:${effective_ipaddr}/${effective_netmask}", withpath=>false} -> From 9991ccfc6f4d5df41eb0c0c905af853f7bb11911 Mon Sep 17 00:00:00 2001 From: Mike Dorman Date: Fri, 13 Jun 2014 10:04:13 -0600 Subject: [PATCH 12/12] proper logic for $use_ovs_override parameter --- manifests/l3/ifconfig.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index f649eb4..372907e 100644 --- a/manifests/l3/ifconfig.pp +++ b/manifests/l3/ifconfig.pp @@ -128,7 +128,7 @@ ] # Determine if we're using OVS for this interface - $real_use_ovs = $use_ovs_override ? { undef => $::l23network::use_ovs, false => $::l23network::use_ovs, default => $use_ovs_override } + $real_use_ovs = $use_ovs_override ? { undef => $::l23network::use_ovs, default => $use_ovs_override } # Ignore bond slave interfaces if not using OVS $real_bond_ifaces = $interface ? {