cloud-maker 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/cloud-maker +7 -0
- data/lib/cloud-maker.rb +2 -0
- data/lib/cloud_maker/config.rb +16 -1
- data/lib/cloud_maker/ec2.rb +29 -2
- metadata +18 -2
data/bin/cloud-maker
CHANGED
@@ -45,7 +45,14 @@ class CloudMakerCLI < Thor
|
|
45
45
|
say "You can remove this authorization from the GitHub interface if needed."
|
46
46
|
say "Your password will not be saved to disk.".green
|
47
47
|
user = ask("What is your GitHub #{"username".cyan}?")
|
48
|
+
state = Termios.getattr(STDIN)
|
49
|
+
new_settings = state.dup
|
50
|
+
new_settings.c_lflag &= ~(Termios::ECHO | Termios::ICANON)
|
51
|
+
new_settings.c_cc[Termios::VMIN] = 1
|
52
|
+
Termios.setattr(STDIN, Termios::TCSANOW, new_settings)
|
48
53
|
password = ask("What is your GitHub #{"password".cyan}?")
|
54
|
+
Termios.setattr(STDIN, Termios::TCSANOW, state)
|
55
|
+
puts
|
49
56
|
begin
|
50
57
|
response = JSON.parse(RestClient::Request.new(
|
51
58
|
:method => "POST",
|
data/lib/cloud-maker.rb
CHANGED
data/lib/cloud_maker/config.rb
CHANGED
@@ -108,6 +108,20 @@ module CloudMaker
|
|
108
108
|
self['tags']['cloud_maker_config'] = self.config_name
|
109
109
|
end
|
110
110
|
|
111
|
+
def method_missing(method=nil, *args)
|
112
|
+
if method.to_s[-1] == "?"
|
113
|
+
key_name = method.to_s[0, method.to_s.length-1]
|
114
|
+
value = self[key_name]
|
115
|
+
if value.respond_to? :empty?
|
116
|
+
!value.empty?
|
117
|
+
else
|
118
|
+
!value.nil?
|
119
|
+
end
|
120
|
+
else
|
121
|
+
super
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
111
125
|
def config_name
|
112
126
|
files = self.imports.dup
|
113
127
|
files.push self.extra_options['config_path'] if self.extra_options['config_path']
|
@@ -188,8 +202,9 @@ module CloudMaker
|
|
188
202
|
env_run_cmds.push(set_environment_variable_cmd(key, properties["value"]))
|
189
203
|
end
|
190
204
|
end
|
205
|
+
env_run_cmds.push("touch /var/lib/cloud/cloud_init_complete")
|
191
206
|
|
192
|
-
return "#cloud-boothook\n#!/bin/sh\n#{env_run_cmds.join("\n")}\n"
|
207
|
+
return "#cloud-boothook\n#!/bin/sh\nif [ ! -f /var/lib/cloud/cloud_init_complete ]; then\n#{env_run_cmds.join("\n")}\nfi\n"
|
193
208
|
end
|
194
209
|
|
195
210
|
|
data/lib/cloud_maker/ec2.rb
CHANGED
@@ -27,6 +27,7 @@ module CloudMaker
|
|
27
27
|
'description' => "The name of an Amazon key pair, so you can actually login to the instance."
|
28
28
|
},
|
29
29
|
'elastic_ip' => {
|
30
|
+
'default' => '',
|
30
31
|
'description' => "An elastic IP address you control that you would like to associate to the instance."
|
31
32
|
},
|
32
33
|
'security_group' => {
|
@@ -37,6 +38,10 @@ module CloudMaker
|
|
37
38
|
'iam_role' => {
|
38
39
|
'default' => '',
|
39
40
|
'description' => 'The IAM instance profile name or ARN you would like to use.'
|
41
|
+
},
|
42
|
+
'cname' => {
|
43
|
+
'default' => '',
|
44
|
+
'description' => "A dns entry you would like to CNAME to this instance."
|
40
45
|
}
|
41
46
|
}
|
42
47
|
}
|
@@ -114,11 +119,33 @@ module CloudMaker
|
|
114
119
|
|
115
120
|
instance.tags.set(cloud_maker_config['tags']) if cloud_maker_config['tags']
|
116
121
|
|
117
|
-
if cloud_maker_config
|
122
|
+
if cloud_maker_config.elastic_ip? || cloud_maker_config.cname?
|
118
123
|
while instance.status == :pending
|
119
124
|
#wait
|
120
125
|
end
|
121
|
-
instance.associate_elastic_ip(cloud_maker_config["elastic_ip"])
|
126
|
+
instance.associate_elastic_ip(cloud_maker_config["elastic_ip"]) if cloud_maker_config.elastic_ip?
|
127
|
+
|
128
|
+
if cloud_maker_config.cname?
|
129
|
+
r53 = AWS::Route53::Client.new(:access_key_id => self.aws_access_key_id, :secret_access_key => self.aws_secret_access_key)
|
130
|
+
|
131
|
+
zone = r53.list_hosted_zones[:hosted_zones].select {|zone|
|
132
|
+
cloud_maker_config['cname'] + '.' =~ /#{Regexp.escape(zone[:name])}$/
|
133
|
+
}.first
|
134
|
+
|
135
|
+
r53.change_resource_record_sets(
|
136
|
+
:hosted_zone_id => zone[:id],
|
137
|
+
:change_batch => {
|
138
|
+
:comment => "CloudMaker initialization of #{instance.instance_id}.", :changes => [{
|
139
|
+
:action => "CREATE", :resource_record_set => {
|
140
|
+
:name => cloud_maker_config['cname'],
|
141
|
+
:type => 'CNAME',
|
142
|
+
:ttl => 60,
|
143
|
+
:resource_records => [{:value => instance.dns_name}]
|
144
|
+
}
|
145
|
+
}]
|
146
|
+
}
|
147
|
+
)
|
148
|
+
end
|
122
149
|
end
|
123
150
|
|
124
151
|
archiver = S3Archiver.new(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud-maker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: colorize
|
@@ -92,6 +92,22 @@ dependencies:
|
|
92
92
|
- - ~>
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '1.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: ruby-termios
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0.9'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.9'
|
95
111
|
- !ruby/object:Gem::Dependency
|
96
112
|
name: pry
|
97
113
|
requirement: !ruby/object:Gem::Requirement
|