<commit_before># Forked from https://github.com/fup/puppet-ssh @ 59684a8ae174
#
# Takes a Hash of config arguments:
#   Required parameters:
#     :name   (the name of the key - e.g 'my_ssh_key')
#     :request (what type of return value is requested (public, private, auth, known)
#
#   Optional parameters:
#     :type    (the key type - default: 'rsa')
#     :dir     (the subdir of /etc/puppet/ to store the key in - default: 'ssh')
#     :hostkey (weither the key should be a hostkey or not. defines weither to add it to known_hosts or not)
#     :authkey (weither the key is an authkey or not. defines weither to add it to authorized_keys or not)
#
require 'fileutils'
module Puppet::Parser::Functions
  newfunction(:ssh_keygen, :type => :rvalue) do |args|
    unless args.first.class == Hash then
      raise Puppet::ParseError, "ssh_keygen(): config argument must be a Hash"
    end

    config = args.first

    config = {
      'dir'                     => 'ssh',
      'type'                    => 'rsa',
      'hostkey'                 => false,
      'authkey'                 => false,
      'request'                 => nil,
      'comment'                 => nil,
    }.merge(config)

    if config['request'].nil?
        raise Puppet::ParseError, "ssh_keygen(): request argument is required"
    end

    if config['name'].nil?<commit_msg>require name argument only for actions acting on keyfiles<commit_after># Forked from https://github.com/fup/puppet-ssh @ 59684a8ae174
#
# Takes a Hash of config arguments:
#   Required parameters:
#     :name   (the name of the key - e.g 'my_ssh_key')
#     :request (what type of return value is requested (public, private, auth, known)
#
#   Optional parameters:
#     :type    (the key type - default: 'rsa')
#     :dir     (the subdir of /etc/puppet/ to store the key in - default: 'ssh')
#     :hostkey (weither the key should be a hostkey or not. defines weither to add it to known_hosts or not)
#     :authkey (weither the key is an authkey or not. defines weither to add it to authorized_keys or not)
#
require 'fileutils'
module Puppet::Parser::Functions
  newfunction(:ssh_keygen, :type => :rvalue) do |args|
    unless args.first.class == Hash then
      raise Puppet::ParseError, "ssh_keygen(): config argument must be a Hash"
    end

    config = args.first

    config = {
      'dir'                     => 'ssh',
      'type'                    => 'rsa',
      'hostkey'                 => false,
      'authkey'                 => false,
      'request'                 => nil,
      'comment'                 => nil,
    }.merge(config)

    if config['request'].nil?
        raise Puppet::ParseError, "ssh_keygen(): request argument is required"
    end

    if config['name'].nil? and (request != 'authorized_keys' and request != 'known_hosts)
{'fraction_non_alphanumeric': 0.11378943637008153, 'fraction_numerical': 0.006380716058135413, 'mean_word_length': 2.3239104829210837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6070194', 'n_tokens_mistral': 888, 'n_tokens_neox': 844, 'n_words': 295}