Created
August 17, 2012 15:56
-
-
Save jbouse/3380125 to your computer and use it in GitHub Desktop.
Puppet parser function to return an array of AWS ElastiCache cluster nodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'fog' | |
module Puppet::Parser::Functions | |
newfunction(:ecGetMembers, :type => :rvalue) do |args| | |
raise(Puppet::ParseError, "ecGetMembers(): wrong number of arguments(#{args.length}; must be 1)") if args.size != 1 | |
params = {} | |
params[:ecc] = args[0] | |
Fog.credentials_path = '/etc/puppet/fog_cred' | |
@ecc = Fog::AWS::Elasticache.new() | |
@ec = @ecc.clusters.get(params[:ecc]) | |
nodes = Array.new | |
#check to see if the cluster is registered and ready | |
if @ec and @ec.ready?() | |
@ec.nodes.each { |n| nodes << "#{n['Address']}:#{n['Port']}" } | |
end | |
nodes | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment