awsome 0.0.11 → 0.0.12
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/lib/awsome/ec2.rb +11 -0
- data/lib/awsome/ec2/instance.rb +22 -0
- data/lib/awsome/executor.rb +6 -0
- data/lib/awsome/instance_requirement.rb +9 -1
- metadata +1 -1
data/lib/awsome/ec2.rb
CHANGED
@@ -124,6 +124,17 @@ module Awsome
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
@@associate_address_columns = %w(
|
128
|
+
identifier
|
129
|
+
elastic_ip
|
130
|
+
instance_id
|
131
|
+
)
|
132
|
+
|
133
|
+
def self.associate_address(instance_id, ip_address)
|
134
|
+
cmd = Awsome::Ec2.command('ec2-associate-address', ip_address, instance: instance_id)
|
135
|
+
Awsome.execute(cmd, columns: @@associate_address_columns, filter: /^ADDRESS/)
|
136
|
+
end
|
137
|
+
|
127
138
|
def self.attach_volume(volume_id, instance_id, device)
|
128
139
|
cmd = Awsome::Ec2.command('ec2-attach-volume', volume_id, instance: instance_id, device: device)
|
129
140
|
Awsome.execute(cmd)
|
data/lib/awsome/ec2/instance.rb
CHANGED
@@ -33,6 +33,28 @@ module Awsome
|
|
33
33
|
Awsome::Ssh.ssh(@properties['public_dns_name'], *args)
|
34
34
|
end
|
35
35
|
|
36
|
+
def associate_ips(*elastic_ips)
|
37
|
+
elastic_ips.each do |ip|
|
38
|
+
Awsome::Ec2.associate_address(@properties['instance_id'], ip)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def install_hosts_entries(ip_address, *hostnames)
|
43
|
+
sed = []
|
44
|
+
cmd = []
|
45
|
+
|
46
|
+
# we will remove all hosts entries for the given "ip_address"
|
47
|
+
sed << "sed '/^#{ip_address}/d"
|
48
|
+
|
49
|
+
# we will remove all hosts entries for each of the given "hostnames"
|
50
|
+
sed += hostnames.collect { |h| "sed '/ #{h} /d'" }
|
51
|
+
|
52
|
+
cmd << "sudo cat /etc/hosts | #{sed.join(' | ')} > /etc/hosts.temp"
|
53
|
+
cmd << "sudo echo '#{ip_address} #{hostnames.join(' ')} # GENERATED' >> /etc/hosts.temp"
|
54
|
+
cmd << "sudo mv /etc/hosts.temp /etc/hosts"
|
55
|
+
ssh(cmd)
|
56
|
+
end
|
57
|
+
|
36
58
|
def reattach_volumes(*volumes)
|
37
59
|
volumes.each do |info|
|
38
60
|
Awsome::Ec2.detach_volume(info['id'], info['dir'], info['preumount'])
|
data/lib/awsome/executor.rb
CHANGED
@@ -57,6 +57,12 @@ module Awsome
|
|
57
57
|
instance.deregister_from_elbs
|
58
58
|
instance.remove_packages(*requirement.packages_to_remove(instance))
|
59
59
|
instance.install_packages(*requirement.packages_to_install(instance))
|
60
|
+
|
61
|
+
instances_to_use do |other_instance, other_requirement|
|
62
|
+
other_instance.install_hosts_entries(instance.properties['private_dns_name'], *requirement.hostnames)
|
63
|
+
end
|
64
|
+
|
65
|
+
instance.associate_ips(*requirement.elastic_ips)
|
60
66
|
instance.register_with_elbs(*requirement.elbs)
|
61
67
|
end
|
62
68
|
end
|
@@ -9,7 +9,15 @@ module Awsome
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def elbs
|
12
|
-
@properties['elbs']
|
12
|
+
@properties['elbs'] || []
|
13
|
+
end
|
14
|
+
|
15
|
+
def elastic_ips
|
16
|
+
@properties['elastic_ips'] || []
|
17
|
+
end
|
18
|
+
|
19
|
+
def hostnames
|
20
|
+
@properties['hostnames'] || []
|
13
21
|
end
|
14
22
|
|
15
23
|
def volumes_to_attach(instance)
|