Puppet Function: redis_get_instances

Defined in:
modules/redis/lib/puppet/parser/functions/redis_get_instances.rb
Function type:
Ruby 3.x API

Overview

redis_get_instances()Any

Returns:

  • (Any)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'modules/redis/lib/puppet/parser/functions/redis_get_instances.rb', line 7

newfunction(:redis_get_instances, :type => :rvalue, :arity => 2) do |args|
  ip = args[0]
  shards = args[1]
  instances = []
  site = compiler.topscope.lookupvar('site')
  shards[site].each do |_, data|
    if data['host'] == ip
      instances << data['port'].to_s
    end
  end

  if instances.empty?
    fail(Puppet::ParseError, "No Redis instances found for #{ip}:#{port}")
  end

  instances.sort
end