Module: Awsborn
- Defined in:
- lib/awsborn/ec2.rb,
lib/awsborn/elb.rb,
lib/awsborn/rake.rb,
lib/awsborn/server.rb,
lib/awsborn/awsborn.rb,
lib/awsborn/route53.rb,
lib/awsborn/keychain.rb,
lib/awsborn/git_branch.rb,
lib/awsborn/aws_constants.rb,
lib/awsborn/load_balancer.rb,
lib/awsborn/server_cluster.rb,
lib/awsborn/known_hosts_updater.rb
Defined Under Namespace
Modules: AwsConstants, Chef
Classes: Ec2, Elb, GitBranch, Keychain, KnownHostsUpdater, LoadBalancer, Route53, SecurityError, Server, ServerCluster, ServerError, UnknownConstantError
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.access_key_id ⇒ Object
11
12
13
|
# File 'lib/awsborn/awsborn.rb', line 11
def access_key_id
@access_key_id ||= ENV['AMAZON_ACCESS_KEY_ID']
end
|
.chef_log_level ⇒ Object
84
85
86
|
# File 'lib/awsborn/awsborn.rb', line 84
def chef_log_level
@chef_log_level || :info
end
|
.logger ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/awsborn/awsborn.rb', line 45
def logger
unless defined? @logger
dir = [Dir.pwd, '/tmp'].find { |d| File.writable?(d) }
if dir
file = File.open(File.join(dir, 'awsborn.log'), 'a')
file.sync = true
end
@logger = Logger.new(file || $stdout)
@logger.level = Logger::INFO
end
@logger
end
|
.remote_chef_path ⇒ Object
41
42
43
|
# File 'lib/awsborn/awsborn.rb', line 41
def remote_chef_path
@remote_chef_path ||= '/etc/chef'
end
|
.secret_access_key ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/awsborn/awsborn.rb', line 15
def secret_access_key
unless @secret_access_key
@secret_access_key = ENV['AMAZON_SECRET_ACCESS_KEY']
if @secret_access_key.to_s == ''
@secret_access_key = secret_access_key_from_keychain(access_key_id)
end
end
@secret_access_key.to_s
end
|
.verbose ⇒ Object
Returns the value of attribute verbose.
7
8
9
|
# File 'lib/awsborn/awsborn.rb', line 7
def verbose
@verbose
end
|
Class Method Details
.secret_access_key_from_keychain(key_id) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/awsborn/awsborn.rb', line 25
def secret_access_key_from_keychain (key_id)
@credentials ||= {}
unless @credentials[key_id]
dump = `security -q find-generic-password -a "#{key_id}" -g 2>&1`
secret_key = dump[/password: "(.*)"/, 1]
@credentials[key_id] = secret_key
end
@credentials[key_id]
end
|
.secret_access_key_from_keychain!(key_id) ⇒ Object
35
36
37
38
39
|
# File 'lib/awsborn/awsborn.rb', line 35
def secret_access_key_from_keychain! (key_id)
secret = secret_access_key_from_keychain key_id
raise "Could not find secret access key for #{key_id}" if secret.to_s == ''
secret
end
|
.verbose_output(message) ⇒ Object
80
81
82
|
# File 'lib/awsborn/awsborn.rb', line 80
def verbose_output(message)
puts message if Awsborn.verbose
end
|
.wait_for(message, sleep_seconds = 5, max_wait_seconds = nil) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/awsborn/awsborn.rb', line 59
def wait_for (message, sleep_seconds = 5, max_wait_seconds = nil)
stdout_sync = $stdout.sync
$stdout.sync = true
start_at = Time.now
print "Waiting for #{message}.." if Awsborn.verbose
result = yield
while ! result
if max_wait_seconds && Time.now > start_at + max_wait_seconds
raise Interrupt, "Timed out after #{Time.now - start_at} seconds."
end
print "." if Awsborn.verbose
sleep sleep_seconds
result = yield
end
verbose_output "OK!"
result
ensure
$stdout.sync = stdout_sync
end
|