]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb
generate TLSA record for our mailserver ports
[dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / gen_tlsa_entry.rb
diff --git a/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb b/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb
new file mode 100644 (file)
index 0000000..7c07b7c
--- /dev/null
@@ -0,0 +1,16 @@
+module Puppet::Parser::Functions
+  newfunction(:gen_tlsa_entry, :type => :rvalue) do |args|
+    certfile = args.shift()
+    hostname = args.shift()
+    port = args.shift()
+
+    if File.exist?(certfile)
+      cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname]
+      IO.popen(cmd, "r") {|i|
+        return i.read
+      }
+    else
+      return "; certfile #{certfile} did not exist to create TLSA record for #{hostname}:#{port}."
+    end
+  end
+end