Skip to content

Commit

Permalink
Do not fail miserabily if users try to use the deprecated is_slave pa…
Browse files Browse the repository at this point in the history
…rameter
  • Loading branch information
Davide Ferrari committed May 29, 2015
1 parent 524817f commit dab4e32
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions manifests/zone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
$zone_forwarders = undef,
$zone_origin = undef,
$zone_notify = undef,
$is_slave = false,
) {

include ::bind::params
Expand All @@ -44,6 +45,7 @@
validate_re($ensure, ['present', 'absent'],
"\$ensure must be either 'present' or 'absent', got '${ensure}'")

validate_bool($is_slave)
validate_bool($is_dynamic)
validate_array($allow_update)
validate_string($transfer_source)
Expand All @@ -58,11 +60,19 @@

validate_string($zone_origin)

if ($zone_type != 'master' and $is_dynamic) {
fail "Zone '${name}' cannot be ${zone_type} AND dynamic!"
# add backwards support for is_slave parameter
if ($is_slave) and ($zone_type == 'master') {
warning('$is_slave is deprecated. You should set $zone_type = \'master\'')
$int_zone_type = 'slave'
} else {
$int_zone_type = $zone_type
}

if ($transfer_source and $zone_type != 'slave') {
if ($int_zone_type != 'master' and $is_dynamic) {
fail "Zone '${name}' cannot be ${int_zone_type} AND dynamic!"
}

if ($transfer_source and $int_zone_type != 'slave') {
fail "Zone '${name}': transfer_source can be set only for slave zones!"
}

Expand All @@ -89,7 +99,7 @@
require => Package['bind9'],
}

case $zone_type {
case $int_zone_type {
'master': {
validate_re($zone_contact, '^\S+$', "Wrong contact value for ${name}!")
validate_slength($zone_ns, 255, 3)
Expand Down Expand Up @@ -151,7 +161,7 @@
content => template('bind/zone-forward.erb'),
}
}
default: { fail("Zone type '${zone_type}' not supported.") }
default: { fail("Zone type '${int_zone_type}' not supported.") }
}
}
'absent': {
Expand Down

0 comments on commit dab4e32

Please sign in to comment.