1 module Puppet::Parser::Functions
2 newfunction(:gen_tlsa_entry, :type => :rvalue) do |args|
3 certfile = args.shift()
4 hostname = args.shift()
7 if port.kind_of?(Array)
13 if certfile.kind_of?(Array)
20 certs.each do |certfile|
21 res << "; cert #{certfile} for #{hostname}:#{ports}."
23 if File.exist?(certfile)
24 cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname]
26 IO.popen(cmd, "r") {|i| res << i.read }
28 res << "; Failed to find swede"
31 res << "; certfile #{certfile} did not exist to create TLSA record for #{hostname}:#{port}."
34 cfnew = certfile.gsub(/\.crt$/, '-new.crt')
35 if cfnew != certfile and File.exist?(cfnew)
36 cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', cfnew, '--port', port.to_s, hostname]
38 IO.popen(cmd, "r") {|i| new_entry = i.read }
39 if not res.include?(new_entry)