diff --git a/manifests/if/dynamic.pp b/manifests/if/dynamic.pp index c66ec298..1f08d5dc 100644 --- a/manifests/if/dynamic.pp +++ b/manifests/if/dynamic.pp @@ -4,13 +4,16 @@ # # === Parameters: # -# $ensure - required - up|down -# $macaddress - optional - defaults to macaddress_$title -# $bootproto - optional - defaults to "dhcp" -# $userctl - optional - defaults to false -# $mtu - optional -# $dhcp_hostname - optional -# $ethtool_opts - optional +# $ensure - required - up|down +# $macaddress - optional - defaults to macaddress_$title +# $bootproto - optional - defaults to "dhcp" +# $userctl - optional - defaults to false +# $mtu - optional +# $dhcp_hostname - optional +# $ethtool_opts - optional +# $peerdns - optional +# $linkdelay - optional +# $check_link_down - optional # # === Actions: # @@ -39,13 +42,15 @@ # define network::if::dynamic ( $ensure, - $macaddress = undef, - $bootproto = 'dhcp', - $userctl = false, - $mtu = undef, - $dhcp_hostname = undef, - $ethtool_opts = undef, - $linkdelay = undef + $macaddress = undef, + $bootproto = 'dhcp', + $userctl = false, + $mtu = undef, + $dhcp_hostname = undef, + $ethtool_opts = undef, + $peerdns = false, + $linkdelay = undef, + $check_link_down = false ) { # Validate our regular expressions $states = [ '^up$', '^down$' ] @@ -60,18 +65,21 @@ } # Validate booleans validate_bool($userctl) + validate_bool($peerdns) network_if_base { $title: - ensure => $ensure, - ipaddress => '', - netmask => '', - gateway => '', - macaddress => $macaddy, - bootproto => $bootproto, - userctl => $userctl, - mtu => $mtu, - dhcp_hostname => $dhcp_hostname, - ethtool_opts => $ethtool_opts, - linkdelay => $linkdelay, + ensure => $ensure, + ipaddress => '', + netmask => '', + gateway => '', + macaddress => $macaddy, + bootproto => $bootproto, + userctl => $userctl, + mtu => $mtu, + dhcp_hostname => $dhcp_hostname, + ethtool_opts => $ethtool_opts, + peerdns => $peerdns, + linkdelay => $linkdelay, + check_link_down => $check_link_down, } } # define network::if::dynamic diff --git a/manifests/init.pp b/manifests/init.pp index 65bd4b2f..01e26004 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,23 +49,26 @@ # # === Parameters: # -# $ensure - required - up|down -# $ipaddress - required -# $netmask - required -# $macaddress - required -# $gateway - optional -# $bootproto - optional -# $userctl - optional - defaults to false -# $mtu - optional -# $dhcp_hostname - optional -# $ethtool_opts - optional -# $bonding_opts - optional -# $isalias - optional -# $peerdns - optional -# $dns1 - optional -# $dns2 - optional -# $domain - optional -# $bridge - optional +# $ensure - required - up|down +# $ipaddress - required +# $netmask - required +# $macaddress - required +# $gateway - optional +# $bootproto - optional +# $userctl - optional - defaults to false +# $mtu - optional +# $dhcp_hostname - optional +# $ethtool_opts - optional +# $bonding_opts - optional +# $isalias - optional +# $peerdns - optional +# $dns1 - optional +# $dns2 - optional +# $domain - optional +# $bridge - optional +# $linkdelay - optional +# $check_link_down - optional + # # === Actions: # @@ -97,25 +100,26 @@ $ipaddress, $netmask, $macaddress, - $gateway = undef, - $ipv6address = undef, - $ipv6gateway = undef, - $ipv6init = false, - $ipv6autoconf = false, - $bootproto = 'none', - $userctl = false, - $mtu = undef, - $dhcp_hostname = undef, - $ethtool_opts = undef, - $bonding_opts = undef, - $isalias = false, - $peerdns = false, - $ipv6peerdns = false, - $dns1 = undef, - $dns2 = undef, - $domain = undef, - $bridge = undef, - $linkdelay = undef + $gateway = undef, + $ipv6address = undef, + $ipv6gateway = undef, + $ipv6init = false, + $ipv6autoconf = false, + $bootproto = 'none', + $userctl = false, + $mtu = undef, + $dhcp_hostname = undef, + $ethtool_opts = undef, + $bonding_opts = undef, + $isalias = false, + $peerdns = false, + $ipv6peerdns = false, + $dns1 = undef, + $dns2 = undef, + $domain = undef, + $bridge = undef, + $linkdelay = undef, + $check_link_down = false ) { # Validate our booleans validate_bool($userctl) @@ -124,6 +128,7 @@ validate_bool($ipv6init) validate_bool($ipv6autoconf) validate_bool($ipv6peerdns) + validate_bool($check_link_down) # Validate our regular expressions $states = [ '^up$', '^down$' ] validate_re($ensure, $states, '$ensure must be either "up" or "down".') diff --git a/spec/defines/network_if_dynamic_spec.rb b/spec/defines/network_if_dynamic_spec.rb index 477a8d2a..1de7eb37 100644 --- a/spec/defines/network_if_dynamic_spec.rb +++ b/spec/defines/network_if_dynamic_spec.rb @@ -51,14 +51,16 @@ context 'optional parameters' do let(:title) { 'eth99' } let :params do { - :ensure => 'down', - :macaddress => 'ef:ef:ef:ef:ef:ef', - :bootproto => 'bootp', - :userctl => true, - :mtu => '1500', - :ethtool_opts => 'speed 100 duplex full autoneg off', - :dhcp_hostname => 'hostname', - :linkdelay => '5', + :ensure => 'down', + :macaddress => 'ef:ef:ef:ef:ef:ef', + :bootproto => 'bootp', + :userctl => true, + :mtu => '1500', + :dhcp_hostname => 'hostname', + :ethtool_opts => 'speed 100 duplex full autoneg off', + :peerdns => true, + :linkdelay => '5', + :check_link_down => true, } end let :facts do { diff --git a/templates/ifcfg-eth.erb b/templates/ifcfg-eth.erb index 42b2065b..768b44df 100644 --- a/templates/ifcfg-eth.erb +++ b/templates/ifcfg-eth.erb @@ -3,16 +3,16 @@ ### DEVICE=<%= @interface %> BOOTPROTO=<%= @bootproto %> -<% if @macaddress %>HWADDR=<%= @macaddress %> +<% if @macaddress and @macaddress != '' %>HWADDR=<%= @macaddress %> <% end -%> ONBOOT=<%= @onboot %> HOTPLUG=<%= @onboot %> TYPE=Ethernet -<% if @ipaddress %>IPADDR=<%= @ipaddress %> +<% if @ipaddress and @ipaddress != '' %>IPADDR=<%= @ipaddress %> <% end -%> -<% if @netmask %>NETMASK=<%= @netmask %> +<% if @netmask and @netmask != '' %>NETMASK=<%= @netmask %> <% end -%> -<% if @gateway %>GATEWAY=<%= @gateway %> +<% if @gateway and @gateway != '' %>GATEWAY=<%= @gateway %> <% end -%> <% if @mtu %>MTU=<%= @mtu %> <% end -%> @@ -50,4 +50,9 @@ IPV6INIT=yes <% end -%> <% if @linkdelay %>LINKDELAY=<%= @linkdelay %> <% end -%> +<% if @check_link_down %> +check_link_down() { + return 1; +} +<% end -%> NM_CONTROLLED=no