From e05a038abc6fcdd3a0552b76e93af0e146b10d25 Mon Sep 17 00:00:00 2001 From: Justin Couch Date: Tue, 6 Jun 2017 15:29:30 +1000 Subject: [PATCH 01/11] Provide a content option for the zone file so that it can be templated externally. --- manifests/zone.pp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/manifests/zone.pp b/manifests/zone.pp index 867697d..2bbdd14 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -19,6 +19,7 @@ $forwarders = '', $forward = '', $source = '', + $content = '', $forwarders_port = 53, ) { # where there is a zone, there is a server @@ -102,14 +103,26 @@ } if member(['init', 'managed'], $zone_file_mode) { - file { "${cachedir}/${name}/${zone_file}": - ensure => present, - owner => $bind_user, - group => $bind_group, - mode => '0644', - replace => ($zone_file_mode == 'managed'), - source => pick($source, 'puppet:///modules/bind/db.empty'), - audit => [ content ], + if ! is_empty($content) { + file { "${cachedir}/${name}/${zone_file}": + ensure => present, + owner => $bind_user, + group => $bind_group, + mode => '0644', + replace => ($zone_file_mode == 'managed'), + content => $content, + audit => [ content ], + } + } else { + file { "${cachedir}/${name}/${zone_file}": + ensure => present, + owner => $bind_user, + group => $bind_group, + mode => '0644', + replace => ($zone_file_mode == 'managed'), + source => pick($source, 'puppet:///modules/bind/db.empty'), + audit => [ content ], + } } } From 86294532f78149240a933d11724f0556807ba07e Mon Sep 17 00:00:00 2001 From: Justin Couch Date: Tue, 6 Jun 2017 15:36:12 +1000 Subject: [PATCH 02/11] Function is empty() not is_empty() --- manifests/zone.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/zone.pp b/manifests/zone.pp index 2bbdd14..ba966e8 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -103,7 +103,7 @@ } if member(['init', 'managed'], $zone_file_mode) { - if ! is_empty($content) { + if ! empty($content) { file { "${cachedir}/${name}/${zone_file}": ensure => present, owner => $bind_user, From 3d6656f16c87c201e954e9ed64e9a49d517b8ba7 Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 19:41:44 +1000 Subject: [PATCH 03/11] Don't delete the file after finishing so we can debug the update call. --- lib/puppet_bind/provider/nsupdate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index 7aad48e..2501583 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -57,7 +57,7 @@ def update(&block) else nsupdate(file.path) end - file.unlink + #file.unlink end def accio(file) From 734763e2e08ac3f33eb9604474f367c38f09ecc8 Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 19:45:51 +1000 Subject: [PATCH 04/11] Try spamming debug instead. --- lib/puppet_bind/provider/nsupdate.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index 2501583..660872b 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -57,7 +57,9 @@ def update(&block) else nsupdate(file.path) end - #file.unlink + text = File.read(file.path) + puts text + file.unlink end def accio(file) From b1dbb1befcbdffc0d207caed518e55b1120c48c2 Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 19:52:06 +1000 Subject: [PATCH 05/11] Debug on not-success. --- lib/puppet_bind/provider/nsupdate.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index 660872b..870def9 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -57,8 +57,6 @@ def update(&block) else nsupdate(file.path) end - text = File.read(file.path) - puts text file.unlink end @@ -66,12 +64,17 @@ def accio(file) rrdata_adds.each do |datum| file.write "update add #{name}. #{resource[:ttl]} #{rrclass} #{type} #{maybe_quote(type, datum)}\n" end + text = File.read(file.path) + puts text + end def destructo(file) rrdata_deletes.each do |datum| file.write "update delete #{name}. #{ttl} #{rrclass} #{type} #{maybe_quote(type, datum)}\n" end + text = File.read(file.path) + puts text end def quoted_type?(type) From 0fdf1bf19701a0e10b381d038e24cd0054b15ae9 Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 19:56:14 +1000 Subject: [PATCH 06/11] Try a different place for debugs. --- lib/puppet_bind/provider/nsupdate.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index 870def9..d80d641 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -31,6 +31,9 @@ def flush accio(file) destructo(file) end + + text = File.read(file.path) + puts text end def ttl @@ -64,17 +67,12 @@ def accio(file) rrdata_adds.each do |datum| file.write "update add #{name}. #{resource[:ttl]} #{rrclass} #{type} #{maybe_quote(type, datum)}\n" end - text = File.read(file.path) - puts text - end def destructo(file) rrdata_deletes.each do |datum| file.write "update delete #{name}. #{ttl} #{rrclass} #{type} #{maybe_quote(type, datum)}\n" end - text = File.read(file.path) - puts text end def quoted_type?(type) From 18d80cb8268cae69854d6bbb63090f116967d749 Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 19:58:02 +1000 Subject: [PATCH 07/11] Simplify. --- lib/puppet_bind/provider/nsupdate.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index d80d641..878eb6a 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -31,9 +31,7 @@ def flush accio(file) destructo(file) end - - text = File.read(file.path) - puts text + puts File.read(file) end def ttl From 7c141bcab6b007f053477e213c5c78e867c510dc Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 20:00:46 +1000 Subject: [PATCH 08/11] Print out just before running nsupdate. --- lib/puppet_bind/provider/nsupdate.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index 878eb6a..e2f3cbf 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -31,7 +31,6 @@ def flush accio(file) destructo(file) end - puts File.read(file) end def ttl @@ -51,6 +50,8 @@ def update(&block) yield file file.write "send\n" file.close + puts File.read(file.path) + if keyed? nsupdate('-y', tsig_param, file.path) elsif keyfile? From e11ff0740de4b7afd978853baece4cae77918163 Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 21:02:09 +1000 Subject: [PATCH 09/11] Comment out debug println. --- lib/puppet_bind/provider/nsupdate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index e2f3cbf..d2a0c14 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -50,7 +50,7 @@ def update(&block) yield file file.write "send\n" file.close - puts File.read(file.path) + #puts File.read(file.path) if keyed? nsupdate('-y', tsig_param, file.path) From ed0d6762afe0ec3f97a94568364572f07b224100 Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 22:29:04 +1000 Subject: [PATCH 10/11] Debug print again for remote apex handling. --- lib/puppet_bind/provider/nsupdate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index d2a0c14..e2f3cbf 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -50,7 +50,7 @@ def update(&block) yield file file.write "send\n" file.close - #puts File.read(file.path) + puts File.read(file.path) if keyed? nsupdate('-y', tsig_param, file.path) From c213c503fdf1f525fe7ffaaf1031c0c9f327838e Mon Sep 17 00:00:00 2001 From: justinc Date: Wed, 5 Jul 2017 22:34:10 +1000 Subject: [PATCH 11/11] Disable debug again. --- lib/puppet_bind/provider/nsupdate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_bind/provider/nsupdate.rb b/lib/puppet_bind/provider/nsupdate.rb index e2f3cbf..d2a0c14 100644 --- a/lib/puppet_bind/provider/nsupdate.rb +++ b/lib/puppet_bind/provider/nsupdate.rb @@ -50,7 +50,7 @@ def update(&block) yield file file.write "send\n" file.close - puts File.read(file.path) + #puts File.read(file.path) if keyed? nsupdate('-y', tsig_param, file.path)