1 module Puppet::Parser::Functions
2 newfunction(:gen_tlsa_entry, :type => :rvalue) do |args|
3 certfile = args.shift()
4 hostname = args.shift()
8 if File.exist?(certfile)
9 cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname]
10 IO.popen(cmd, "r") {|i| res << i.read }
12 res << "; certfile #{certfile} did not exist to create TLSA record for #{hostname}:#{port}."
15 if certfile.gsub!(/\.crt$/, '-new.crt') and File.exist?(certfile)
16 cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname]
18 IO.popen(cmd, "r") {|i| new_entry = i.read }
19 if not res.include?(new_entry)