Puppet::Type.newtype(:dns_zone2, :self_refresh => true) do @doc = %q{ } newproperty(:ensure) do newvalue(:present) do provider.write_zone (resource.should_content) end # This should ideally remove the zone. This is however managed # "higher" up in the puppet code. # dns::init has a purge on the directory, and the named # configuration file is fully managed by us. # This means that decomissioning is as simple as removing the zone # from the puppet environment. newvalue(:absent) do # provider.destroy end defaultto :present def retrieve if provider.exists? :present else :absent end end end def refresh provider.write_zone(should_content) end newparam(:origin, :namevar => true) do munge do |value| if value[-1] == '.' value else "#{value}." end end end newparam(:cls) do defaultto :IN end newparam(:view) do defaultto '_default' end newparam(:type) do newvalues(:master, :slave, :mirror, :hint, :stub, :static_stub, :forward, :redirect) aliasvalue :primary, :master aliasvalue :secondary, :slave defaultto :master end newparam(:default_ttl) do defaultto '300' end newparam(:mname) do munge do |value| if value[-1] == '.' value else "#{value}." end end end newparam(:rname) do munge do |value| if value[-1] == '.' value else "#{value}." end end end newparam(:soa_ttl) do end newparam(:refresh) do end newparam(:retry) do end newparam(:expire) do end newparam(:negative_ttl) do end # List of all DNS records (at all) # # Should ideally be limited to records in this zone here instead of # further down. def records catalog.resources.filter do |r| r.is_a?(Puppet::Type.type(:dns_record2)) end end # Create the file resource for us. # This prevents the directory purge on /var/named/zones from deleting us. def generate [Puppet::Type.type(:file).new({ ensure: :present, path: provider.filename, })] end def should_content provider.zone_content(records) end # def eval_generate # content = should_content # catalog.resource("File[/var/named/zones/#{self[:name]}db]")[:content] = content # # provider.refresh (resource.records) # [catalog.resource("File[/var/named/zones/#{self[:name]}db]")] # end # autorequire(:file) {["/var/named/zones/#{self[:name]}db"]} end