Skip to content

Commit 80f3036

Browse files
author
Yarden Bar
committed
Fix TTL updating
Remove type comparison as we're alredy filtering when we query the zone for the domain. Call record.save only once as it publishes the DNS zone. Per DNS RFC, all records under the same node must have the same TTL
1 parent 35682c4 commit 80f3036

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

lib/puppet/provider/dns_record/dynect.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,21 @@ def flush
101101
r.destroy
102102
publish_zone = true
103103
end
104+
needs_update = false
104105
existing.each do |r|
105-
if r.type != resource[:type]
106-
r.type = resource[:type]
107-
needs_update = true
108-
end
109-
if (! r.ttl.nil?) && r.ttl != resource[:ttl]
106+
if r.ttl != resource[:ttl]
110107
r.ttl = resource[:ttl]
111108
needs_update = true
112109
end
113-
if needs_update
114-
Puppet.debug("Updating #{r.inspect}")
115-
r.save
116-
publish_zone = true
117-
end
118110
content_dup -= [r.rdata['address']]
119111
end
112+
if needs_update
113+
Puppet.debug("Updating #{resource[:name]}")
114+
# Calling 'save' applys changes on all DNS node records and 'publish's
115+
# the zone. so it's enough to call save on the 1st record
116+
existing[0].save(true) # replace
117+
publish_zone = true
118+
end
120119
Puppet.debug("content_dup-2: #{content_dup}")
121120
# The remaining records in content_dup are 'new' and should be created
122121
if !content_dup.empty?

0 commit comments

Comments
 (0)