Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PERSISTENT_DHCLIENT #125

Closed
wants to merge 1 commit into from
Closed
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
91 changes: 47 additions & 44 deletions manifests/if/dynamic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
#
# === Parameters:
#
# $ensure - required - up|down
# $macaddress - optional - defaults to macaddress_$title
# $manage_hwaddr - optional - defaults to true
# $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
# $zone - optional
# $metric - optional
# $defroute - optional
# $ensure - required - up|down
# $macaddress - optional - defaults to macaddress_$title
# $manage_hwaddr - optional - defaults to true
# $bootproto - optional - defaults to "dhcp"
# $userctl - optional - defaults to false
# $mtu - optional
# $dhcp_hostname - optional
# $persistent_dhclient - optional - defaults to false
# $ethtool_opts - optional
# $peerdns - optional
# $linkdelay - optional
# $check_link_down - optional
# $zone - optional
# $metric - optional
# $defroute - optional
#
# === Actions:
#
Expand Down Expand Up @@ -46,19 +47,20 @@
#
define network::if::dynamic (
$ensure,
$macaddress = undef,
$manage_hwaddr = true,
$bootproto = 'dhcp',
$userctl = false,
$mtu = undef,
$dhcp_hostname = undef,
$ethtool_opts = undef,
$peerdns = false,
$linkdelay = undef,
$check_link_down = false,
$defroute = undef,
$zone = undef,
$metric = undef
$macaddress = undef,
$manage_hwaddr = true,
$bootproto = 'dhcp',
$userctl = false,
$mtu = undef,
$dhcp_hostname = undef,
$persistent_dhclient = false,
$ethtool_opts = undef,
$peerdns = false,
$linkdelay = undef,
$check_link_down = false,
$defroute = undef,
$zone = undef,
$metric = undef
) {
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
Expand All @@ -77,22 +79,23 @@
validate_bool($manage_hwaddr)

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
netmask => '',
gateway => '',
macaddress => $macaddy,
manage_hwaddr => $manage_hwaddr,
bootproto => $bootproto,
userctl => $userctl,
mtu => $mtu,
dhcp_hostname => $dhcp_hostname,
ethtool_opts => $ethtool_opts,
peerdns => $peerdns,
linkdelay => $linkdelay,
check_link_down => $check_link_down,
defroute => $defroute,
zone => $zone,
metric => $metric,
ensure => $ensure,
ipaddress => '',
netmask => '',
gateway => '',
macaddress => $macaddy,
manage_hwaddr => $manage_hwaddr,
bootproto => $bootproto,
userctl => $userctl,
mtu => $mtu,
dhcp_hostname => $dhcp_hostname,
persistent_dhclient => $persistent_dhclient,
ethtool_opts => $ethtool_opts,
peerdns => $peerdns,
linkdelay => $linkdelay,
check_link_down => $check_link_down,
defroute => $defroute,
zone => $zone,
metric => $metric,
}
} # define network::if::dynamic
108 changes: 56 additions & 52 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,32 @@
#
# === Parameters:
#
# $ensure - required - up|down
# $ipaddress - required
# $netmask - required
# $macaddress - required
# $manage_hwaddr - optional - defaults to true
# $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
# $scope - optional
# $linkdelay - optional
# $check_link_down - optional
# $flush - optional
# $zone - optional
# $metric - optional
# $defroute - optional
# $ensure - required - up|down
# $ipaddress - required
# $netmask - required
# $macaddress - required
# $manage_hwaddr - optional - defaults to true
# $gateway - optional
# $bootproto - optional
# $userctl - optional - defaults to false
# $mtu - optional
# $dhcp_hostname - optional
# $persistent_dhclient - optional - defaults to false
# $ethtool_opts - optional
# $bonding_opts - optional
# $isalias - optional
# $peerdns - optional
# $dns1 - optional
# $dns2 - optional
# $domain - optional
# $bridge - optional
# $scope - optional
# $linkdelay - optional
# $check_link_down - optional
# $flush - optional
# $zone - optional
# $metric - optional
# $defroute - optional
#
# === Actions:
#
Expand All @@ -87,7 +88,6 @@
# SCOPE=
# SRCADDR=
# NOZEROCONF=yes
# PERSISTENT_DHCLIENT=yes|no|1|0
# DHCPRELEASE=yes|no|1|0
# DHCLIENT_IGNORE_GATEWAY=yes|no|1|0
# REORDER_HDR=yes|no
Expand All @@ -105,32 +105,33 @@
$ipaddress,
$netmask,
$macaddress,
$manage_hwaddr = true,
$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,
$scope = undef,
$check_link_down = false,
$flush = false,
$defroute = undef,
$zone = undef,
$metric = undef
$manage_hwaddr = true,
$gateway = undef,
$ipv6address = undef,
$ipv6gateway = undef,
$ipv6init = false,
$ipv6autoconf = false,
$bootproto = 'none',
$userctl = false,
$mtu = undef,
$dhcp_hostname = undef,
$persistent_dhclient = false,
$ethtool_opts = undef,
$bonding_opts = undef,
$isalias = false,
$peerdns = false,
$ipv6peerdns = false,
$dns1 = undef,
$dns2 = undef,
$domain = undef,
$bridge = undef,
$linkdelay = undef,
$scope = undef,
$check_link_down = false,
$flush = false,
$defroute = undef,
$zone = undef,
$metric = undef
) {
# Validate our booleans
validate_bool($userctl)
Expand All @@ -150,6 +151,9 @@

$interface = $name

# Properly format $persistent_dhclient
$persistent_dhclient_real = bool2num($persistent_dhclient)

# Deal with the case where $dns2 is non-empty and $dns1 is empty.
if $dns2 {
if !$dns1 {
Expand Down
3 changes: 3 additions & 0 deletions templates/ifcfg-eth.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
###
DEVICE=<%= @interface %>
BOOTPROTO=<%= @bootproto %>
<% if @bootproto == 'dhcp' -%>
PERSISTENT_DHCLIENT=<%= @persistent_dhclient_real %>
<% end -%>
<% if @manage_hwaddr and @macaddress and @macaddress != '' -%>
HWADDR=<%= @macaddress %>
<% end -%>
Expand Down
9 changes: 5 additions & 4 deletions tests/if-dhcp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

# normal interface - dhcp
network::if::dynamic { 'eth99':
ensure => 'up',
macaddress => 'ff:aa:ff:aa:ff:aa',
mtu => '1500',
ethtool_opts => 'speed 100 duplex full autoneg off',
ensure => 'up',
macaddress => 'ff:aa:ff:aa:ff:aa',
mtu => '1500',
ethtool_opts => 'speed 100 duplex full autoneg off',
persistent_dhclient => true,
}