diff --git a/manifests/l3/ifconfig.pp b/manifests/l3/ifconfig.pp index ee4a043..0b7f953 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,30 @@ # [*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 +# +# [*routes] +# Static routes to be added for this interface. Format: +# [-net|-host] / [gw ] +# +# [*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. +# +# [*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. @@ -84,6 +113,7 @@ $bond_mode = undef, $bond_miimon = 100, $bond_lacp_rate = 1, + $bond_ifaces = undef, $mtu = undef, $dns_nameservers = undef, $dns_search = undef, @@ -93,6 +123,12 @@ $ifname_order_prefix = false, $check_by_ping = 'gateway', $check_by_ping_timeout = 120, + $bridge = false, + $routes = undef, + $use_ovs_override = undef, + $ovs_extra = undef, + $ovs_options = undef, + $type_override = undef, #todo: label => "XXX", # -- "ip addr add..... label XXX" ){ include ::l23network::params @@ -107,6 +143,15 @@ 'balance-alb' ] + # Determine if we're using OVS for this interface + $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 ? { + /^bond/ => $real_use_ovs ? { true => $bond_ifaces, default => undef }, + default => undef + } + # setup configure method for inteface if $bond_master { $method = 'bondslave' @@ -211,11 +256,12 @@ $vlan_id = $2 $vlan_dev = $1 } - /^(bond\d+)$/: { - if ! $bond_mode { + + /^(bond\d+)/: { + 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 @@ -225,6 +271,26 @@ } } + # 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 = $real_use_ovs ? { + true => 'ovs', + 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}" @@ -287,6 +353,17 @@ 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/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_Debian_bondslave.erb b/templates/ipconfig_Debian_bondslave.erb index ed02a4e..7678887 100644 --- a/templates/ipconfig_Debian_bondslave.erb +++ b/templates/ipconfig_Debian_bondslave.erb @@ -1,3 +1,8 @@ -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 %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% end -%> +<% 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..85db1af 100644 --- a/templates/ipconfig_Debian_dhcp.erb +++ b/templates/ipconfig_Debian_dhcp.erb @@ -1,5 +1,6 @@ -auto <%= interface %> -iface <%= interface %> inet dhcp +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,11 @@ 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 -%> +<% 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 @real_use_ovs %>ovs_bridge <%= @bridge %><% end %> diff --git a/templates/ipconfig_Debian_manual.erb b/templates/ipconfig_Debian_manual.erb index 856f41d..960024f 100644 --- a/templates/ipconfig_Debian_manual.erb +++ b/templates/ipconfig_Debian_manual.erb @@ -1,11 +1,19 @@ -auto <%= interface %> -iface <%= interface %> inet manual +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 +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 %> +<% @routes.each do |route| -%> +up route add <%= route %> dev <%= @interface %> +<% 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 %> +<% if @real_use_ovs %>ovs_bridge <%= @bridge %><% end %> diff --git a/templates/ipconfig_Debian_static.erb b/templates/ipconfig_Debian_static.erb index 2b09637..ae206b7 100644 --- a/templates/ipconfig_Debian_static.erb +++ b/templates/ipconfig_Debian_static.erb @@ -1,8 +1,9 @@ -auto <%= interface %> -iface <%= interface %> inet static +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 %> +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 %> @@ -13,7 +14,14 @@ 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 %> +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 -%> +<% if @ovs_extra %>ovs_extra <%= @ovs_extra %><% end %> +<% if @ovs_options %>ovs_options <%= @ovs_options %><% end %> +<% if @real_use_ovs %>ovs_bridge <%= @bridge %><% end %> diff --git a/templates/ipconfig_RedHat_bondslave.erb b/templates/ipconfig_RedHat_bondslave.erb index e511ba7..3a63984 100644 --- a/templates/ipconfig_RedHat_bondslave.erb +++ b/templates/ipconfig_RedHat_bondslave.erb @@ -1,6 +1,9 @@ -DEVICE=<%= interface %> +DEVICE=<%= @interface %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> BOOTPROTO=none 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..f4ce745 100644 --- a/templates/ipconfig_RedHat_dhcp.erb +++ b/templates/ipconfig_RedHat_dhcp.erb @@ -1,4 +1,6 @@ -DEVICE=<%= interface %> +DEVICE=<%= @interface %> +<% if @iftype %>TYPE=<%= @iftype %><% end %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> BOOTPROTO=dhcp ONBOOT=yes USERCTL=no @@ -8,3 +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 @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 40e061a..2bb4d29 100644 --- a/templates/ipconfig_RedHat_manual.erb +++ b/templates/ipconfig_RedHat_manual.erb @@ -1,4 +1,6 @@ -DEVICE=<%= interface %> +DEVICE=<%= @interface %> +<% if @iftype %>TYPE=<%= @iftype %><% end %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> BOOTPROTO=none ONBOOT=yes USERCTL=no @@ -7,3 +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 @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 d1e6b49..0721516 100644 --- a/templates/ipconfig_RedHat_static.erb +++ b/templates/ipconfig_RedHat_static.erb @@ -1,6 +1,8 @@ -DEVICE=<%= interface %> -IPADDR=<%= effective_ipaddr %> -NETMASK=<%= effective_netmask %> +DEVICE=<%= @interface %> +IPADDR=<%= @effective_ipaddr %> +NETMASK=<%= @effective_netmask %> +<% if @iftype %>TYPE=<%= @iftype %><% end %> +<% if @devtype %>DEVICETYPE="<%= @devtype %>"<% end %> BOOTPROTO=none ONBOOT=yes USERCTL=no @@ -13,3 +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 @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_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 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 -%>