Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 33 additions & 25 deletions manifests/if/dynamic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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$' ]
Expand All @@ -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
77 changes: 41 additions & 36 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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)
Expand All @@ -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".')
Expand Down
18 changes: 10 additions & 8 deletions spec/defines/network_if_dynamic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 9 additions & 4 deletions templates/ifcfg-eth.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down Expand Up @@ -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