From 6d655fbfbc054442ba64d82d78ccab85ca4d4aa9 Mon Sep 17 00:00:00 2001 From: Nate Riffe Date: Sun, 27 Dec 2015 09:22:20 -0600 Subject: [PATCH] When a record is local, require the service --- lib/puppet/type/resource_record.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/puppet/type/resource_record.rb b/lib/puppet/type/resource_record.rb index 655d722..db9c1f6 100644 --- a/lib/puppet/type/resource_record.rb +++ b/lib/puppet/type/resource_record.rb @@ -1,6 +1,20 @@ +require 'socket' +require 'resolv' + Puppet::Type.newtype(:resource_record) do @doc = 'A Resource Record in the Domain Name System' + autorequire(:service) do + reqs = [] + # Depend on the bind service if the record is local + reqs << 'bind' if Socket.ip_address_list.any? do |intf| + Resolv.getaddresses(self[:server]).any? do |addr| + intf.ip_address === addr + end + end + reqs + end + ensurable newparam(:title, :namevar => true) do