Module: AWSCarb
- Defined in:
- lib/aws-carb.rb,
lib/aws-carb/config.rb,
lib/aws-carb/version.rb,
lib/aws-carb/user_data.rb,
lib/aws-carb/services/ec2.rb,
lib/aws-carb/services/route53.rb,
lib/aws-carb/cli_argument_parser.rb
Defined Under Namespace
Modules: CliArgumentParser, Services
Classes: Config, UserData
Constant Summary
collapse
- VERSION =
"0.0.9"
Class Method Summary
collapse
Class Method Details
.banner ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/aws-carb.rb', line 57
def self.banner
banner = <<-HEREDOC.strip_heredoc
:::::::: ::: ::::::::: :::::::::
:+: :+: :+: :+: :+: :+: :+: :+:
+:+ +:+ +:+ +:+ +:+ +:+ +:+
+#+ +#++:++#++: +#++:++#: +#++:++#+
+#+ +#+ +#+ +#+ +#+ +#+ +#+
#+# #+# #+# #+# #+# #+# #+# #+#
######## ### ### ### ### #########
- cloudinit and route53 bootstrap -
HEREDOC
indent = ' ' * 6
puts banner.each_line.map { |line| indent + line }
end
|
.run ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/aws-carb.rb', line 77
def self.run
cli_arguments = CliArgumentParser.parse
banner
@config = Config.instance
@config.create(cli_arguments)
@config.display if $GLOBAL_VERBOSE
@user_data = UserData.instance
combined_user_data = @user_data.create(@config)
@config.config[:ec2][:user_data] = combined_user_data
@user_data.display if @config[:user_data_template][:file] and ($GLOBAL_VERBOSE or @config[:show_parsed_template])
if @config[:route53].andand[:new_dns_records]
@route53 = Services::Route53.instance
@route53.client(@config)
@route53.check_hostname_and_domain_availability
end
@ec2 = Services::Ec2.instance
@ec2.client(@config)
@ec2.create_instance
if @config[:route53].andand[:new_dns_records]
@route53.create_records(@ec2)
end
show_instance_details
end
|
.show_instance_details ⇒ Object
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/aws-carb.rb', line 131
def self.show_instance_details
instance_attributes = []
instance_data = {}
ShellSpinner "# collecting instance data", false do
instance_attributes << @ec2.instance.class.describe_call_attributes.keys
instance_attributes << @ec2.instance.class.reservation_attributes.keys
instance_attributes << @ec2.instance.class.mutable_describe_attributes.keys
instance_attributes.flatten!
begin
instance_attributes.each do |attribute|
next if attribute == :source_dest_check
value = @ec2.instance.send(attribute)
next unless value
next if attribute == :user_data
if value.class == AWS::Core::Data::List
instance_data[attribute] = value.to_a
else
instance_data[attribute] = value
end
end
rescue => e
puts e
end
end
puts
puts "# instance details:"
puts instance_data.to_yaml
puts
summary = <<-HEREDOC.strip_heredoc
# instance summary:
id: #{@ec2.instance.id}
HEREDOC
summary += "public ip: #{@ec2.instance.public_ip_address}\n" if @ec2.instance.public_ip_address
summary += "private ip: #{@ec2.instance.private_ip_address}\n"
summary += "public aws fqdn: #{@ec2.instance.public_dns_name}\n" if @ec2.instance.public_dns_name
summary += "private aws fqdn: #{@ec2.instance.private_dns_name}\n"
unless @config[:route53][:new_dns_records].nil?
summary += "public fqdn: #{@config[:route53][:new_dns_records][:public][:alias]}\n" if @config[:route53][:new_dns_records][:public][:target]
summary += "private fqdn: #{@config[:route53][:new_dns_records][:private][:alias]}\n" if @config[:route53][:new_dns_records][:private][:target]
end
if @ec2.instance.dns_name
summary += <<-HEREDOC.strip_heredoc
# connect:
ssh #{@ec2.instance.dns_name} -l ubuntu
HEREDOC
end
puts summary
end
|