Class: Opsworks::Ssh::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/opsworks/ssh/config.rb,
lib/opsworks/ssh/config/server.rb,
lib/opsworks/ssh/config/version.rb,
lib/opsworks/ssh/config/environment.rb

Defined Under Namespace

Classes: Environment, Server

Constant Summary collapse

TEMPLATE_PATH =
File.expand_path('./config/template.erb', __dir__)
VERSION =
'0.1.0'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



13
14
15
16
# File 'lib/opsworks/ssh/config.rb', line 13

def initialize
  @source = File.read TEMPLATE_PATH
  @template = ERB.new @source
end

Class Method Details

.generate!Object



22
23
24
# File 'lib/opsworks/ssh/config.rb', line 22

def self.generate!
  new.result
end

.opsworksObject



18
19
20
# File 'lib/opsworks/ssh/config.rb', line 18

def self.opsworks
  @opsworks ||= Aws::OpsWorks::Client.new
end

Instance Method Details

#eachObject



26
27
28
29
30
31
32
33
# File 'lib/opsworks/ssh/config.rb', line 26

def each
  raise "No environments found in OpsWorks account" unless environments.any?
  environments.each do |environment|
    environment.servers.each do |server|
      yield "#{environment.name}_#{server.name}", server.ip
    end
  end
end

#resultObject



35
36
37
# File 'lib/opsworks/ssh/config.rb', line 35

def result
  @template.result(binding)
end