One more for you all before I try the cleaned up v...
# puppet
g
One more for you all before I try the cleaned up version of this code... this ruby puppet function generates the contents of a file and there are also ~11,000 of these files (so that many calls to the function)... any tips for optimizing or rewriting it? The function is called
create_rfc4716_authorized_keys
and exists because the
ssh_authorized_keys
type does not produce the format that is needed.
Copy code
pubkeys = args[0]

  	keys_contents = ""

  	pubkeys.each { |pubkey|
  		cmd = "ssh-keygen -e -f /dev/stdin <<< \"#{pubkey}\""
  		# return cmd
      key_contents = "\n" + `#{cmd}`
      key_contents = key_contents.gsub(/^Comment:.*?$/, 'Comment: "Converted by create_rfc4716_authorized_keys.rb"')
		  keys_contents = keys_contents + key_contents
  	}

  	keys_contents = keys_contents + "\n"
  	return keys_contents