X-Git-Url: https://git.donarmstrong.com/?p=dsa-puppet.git;a=blobdiff_plain;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fgen_tlsa_entry.rb;h=1257ae81c9731d5889e9f698b64403bae39bdc5e;hp=7b846b90c327ba98c59ae792b3c26ec17438b27e;hb=cdf648b13dacc11edd25af11c93a67dbe7097743;hpb=a97bb246b7122f4bb7686b9b48ee379e00bf4914 diff --git a/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb b/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb index 7b846b90..1257ae81 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb @@ -4,20 +4,30 @@ module Puppet::Parser::Functions hostname = args.shift() port = args.shift() - res = [] - 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| res << i.read } + if port.kind_of?(Array) + ports = port else - res << "; certfile #{certfile} did not exist to create TLSA record for #{hostname}:#{port}." + ports = [port] end - if certfile.gsub!(/\.crt$/, '-new.crt') and File.exist?(certfile) - cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname] - new_entry = '' - IO.popen(cmd, "r") {|i| new_entry = i.read } - if not res.include?(new_entry) - res << new_entry + res = [] + res << "; cert #{certfile} for #{hostname}:#{ports}." + ports.each do |port| + 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| res << i.read } + else + res << "; certfile #{certfile} did not exist to create TLSA record for #{hostname}:#{port}." + end + + cfnew = certfile.gsub(/\.crt$/, '-new.crt') + if cfnew != certfile and File.exist?(cfnew) + cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', cfnew, '--port', port.to_s, hostname] + new_entry = '' + IO.popen(cmd, "r") {|i| new_entry = i.read } + if not res.include?(new_entry) + res << new_entry + end end end