Puppet Function: validate_yum_hash

Defined in:
lib/puppet/functions/validate_yum_hash.rb
Function type:
Ruby 4.x API

Overview

validate_yum_hash(Any *$args)Any

Parameters:

  • *args (Any)

Returns:

  • (Any)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/puppet/functions/validate_yum_hash.rb', line 1

Puppet::Functions.create_function(:validate_yum_hash) do
  def validate_yum_hash(*args)
    yumrepo_arguments = [
      'name',
      'ensure',
      'baseurl',
      'cost',
      'descr',
      'enabled',
      'enablegroups',
      'exclude',
      'failovermethod',
      'gpgcheck',
      'gpgkey',
      'http_caching',
      'include',
      'includepkgs',
      'keepalive',
      'metadata_expire',
      'metalink',
      'mirrorlist',
      'priority',
      'protect',
      'provider',
      'proxy',
      'proxy_password',
      'proxy_username',
      'repo_gpgcheck',
      's3_enabled',
      'skip_if_unavailable',
      'sslcacert',
      'sslclientcert',
      'sslclientkey',
      'sslverify',
      'target',
      'timeout'
    ]

    if args.size > 1
      raise Puppet::Error, "validate_yum_hash takes only a single argument, #{args.size} provided"
    end
    arg = args[0]

    if not arg.kind_of?(Hash)
      raise Puppet::Error, "non-hash argument provided to validate_yum_hash"
    end

    if arg.size > 0
      arg.each do |title, params|
        params.each do |param, value|
          if ! yumrepo_arguments.include?(param)
            raise Puppet::Error, "Parameter #{param} is not valid for the yumrepo type"
          end
        end
      end
    end
  end
end