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)
14 res << "; cert #{certfile} for #{hostname}:#{ports}."
18 cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', cf, '--port', port.to_s, hostname]
19 IO.popen(cmd, "r") {|i| res << i.read }
21 res << "; certfile #{cf} did not exist to create TLSA record for #{hostname}:#{port}."
24 if cf.gsub!(/\.crt$/, '-new.crt') and File.exist?(cf)
25 cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', cf, '--port', port.to_s, hostname]
27 IO.popen(cmd, "r") {|i| new_entry = i.read }
28 if not res.include?(new_entry)