avst-cloud 0.1.40 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/avst-cloud.gemspec +4 -3
- data/lib/avst-cloud/aws_connection.rb +61 -19
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f348d56f13e9c7215864b65cdf16a6ad0a9aee04732237386a52670089c5bc14
|
4
|
+
data.tar.gz: 207236ddfc0a7a4af10aff90b04cfe720a3fbb7c500d8127dfbdafebb6541a10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96947e2687972300b56c7a45eb12bee1587905da670ced182dd80500b2920eba4771eb0e64a74e25cc83a2fd98977ef0f16172022c4c3cc68003c005938fc78a
|
7
|
+
data.tar.gz: ff541469904187255f7ba20643f1292af2a9379c8046046d1aa0bb13b9088d80be0dcff41eb5d350ee3f0ae6b10aa8a9fc0219f2a318549b959082dafe5ed6f1
|
data/.travis.yml
CHANGED
@@ -2,7 +2,7 @@ language: ruby
|
|
2
2
|
before_install:
|
3
3
|
# https://github.com/travis-ci/travis-rubies/issues/57#issuecomment-458981237
|
4
4
|
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
|
5
|
-
- gem install bundler --version
|
5
|
+
- gem install bundler --version 2.2.10
|
6
6
|
notifications:
|
7
7
|
email: false
|
8
8
|
hipchat:
|
data/avst-cloud.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "avst-cloud"
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.42'
|
8
8
|
spec.authors = ["Martin Brehovsky", "Jon Bevan", "Matthew Hope"]
|
9
9
|
spec.email = ["mbrehovsky@adaptavist.com", "jbevan@adaptavist.com", "mhope@adaptavist.com"]
|
10
10
|
spec.summary = %q{Automated creation, bootstrapping and provisioning of servers }
|
@@ -15,7 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.executables = ["avst-cloud", "avst-cloud-puppet", "avst-cloud-rackspace", "avst-cloud-azure", "avst-cloud-azure-rm"]
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
|
-
spec.
|
18
|
+
spec.required_ruby_version = '~> 2.6.0'
|
19
|
+
spec.add_development_dependency "bundler", "2.2.33"
|
19
20
|
spec.add_development_dependency "rake"
|
20
21
|
spec.add_dependency "fog"
|
21
22
|
spec.add_dependency "fog-core", "1.43.0"
|
@@ -31,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
31
32
|
spec.add_dependency "derelict"
|
32
33
|
spec.add_dependency "docopt", ">= 0.5.0"
|
33
34
|
spec.add_dependency "rainbow", '3.0.0'
|
34
|
-
spec.add_dependency "nokogiri", "~> 1.
|
35
|
+
spec.add_dependency "nokogiri", "~> 1.13.9"
|
35
36
|
spec.add_dependency "signet", "0.14.1"
|
36
37
|
end
|
37
38
|
|
@@ -33,7 +33,7 @@ module AvstCloud
|
|
33
33
|
AvstCloud::AwsServer.new(server, server_name, server.public_ip_address, root_user, root_password)
|
34
34
|
end
|
35
35
|
|
36
|
-
def create_server(server_name, flavour, os, key_name, ssh_key, subnet_id, security_group_ids, ebs_size, hdd_device_path, ami_image_id, availability_zone, additional_hdds={}, vpc=nil, created_by=nil, custom_tags={}, root_username=nil, create_elastic_ip=false, encrypt_root=false ,root_encryption_key=nil, delete_root_disk=true, root_disk_type='gp2', root_disk_iops=0, private_ip=nil)
|
36
|
+
def create_server(server_name, flavour, os, key_name, ssh_key, subnet_id, security_group_ids, ebs_size, hdd_device_path, ami_image_id, availability_zone, additional_hdds={}, vpc=nil, created_by=nil, custom_tags={}, root_username=nil, create_elastic_ip=false, encrypt_root=false ,root_encryption_key=nil, delete_root_disk=true, root_disk_type='gp2', root_disk_iops=0, root_disk_throughput=0, private_ip=nil, public_ip=nil)
|
37
37
|
# Permit named instances from DEFAULT_FLAVOURS
|
38
38
|
flavour = flavour || "t2.micro"
|
39
39
|
os = os || "ubuntu-14"
|
@@ -90,6 +90,31 @@ module AvstCloud
|
|
90
90
|
logger.debug "create_elastic_ip - #{create_elastic_ip}"
|
91
91
|
logger.debug "custom_private_ip - #{private_ip}"
|
92
92
|
|
93
|
+
elastic_ip_address = nil
|
94
|
+
|
95
|
+
# if a public IP has been specified, try to lookup the elastic IP and use it
|
96
|
+
if public_ip
|
97
|
+
require "resolv"
|
98
|
+
# we can find IP based on either its address or its Name tag, if the provided value is not an IP try by tag
|
99
|
+
if public_ip =~ Resolv::IPv4::Regex
|
100
|
+
found_eip = connect.describe_addresses('public-ip' => [public_ip])
|
101
|
+
else
|
102
|
+
found_eip = connect.describe_addresses('tag:Name' => [public_ip])
|
103
|
+
end
|
104
|
+
if ! found_eip.data[:body]['addressesSet'][0].nil?
|
105
|
+
# if we have found the IP and its not already associated use it
|
106
|
+
if found_eip.data[:body]['addressesSet'][0]['publicIp'] and ! found_eip.data[:body]['addressesSet'][0]['associationId']
|
107
|
+
elastic_ip =found_eip.data[:body]['addressesSet'][0]
|
108
|
+
elastic_ip_address = elastic_ip['publicIp']
|
109
|
+
logger.debug "Requested Elastic IP found and is unallocated, an attempt to attach this to the VM will be made"
|
110
|
+
else
|
111
|
+
logger.warn "Requested Elastic IP exist but is already allocated, the system will be created but will NOT use this IP"
|
112
|
+
end
|
113
|
+
else
|
114
|
+
logger.warn "Requested Elastic IP does not exist, the system will be created but will NOT use this IP"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
93
118
|
create_ebs_volume = nil
|
94
119
|
if ebs_size
|
95
120
|
# in case of centos ami we need to use /dev/xvda this is ami dependent
|
@@ -110,8 +135,15 @@ module AvstCloud
|
|
110
135
|
end
|
111
136
|
|
112
137
|
# if this is a provisioned IOPS disk set the iops value
|
113
|
-
if root_disk_type == 'io1'
|
138
|
+
if root_disk_type == 'io1' or root_disk_type == 'io2'
|
114
139
|
root_disk.merge!('Ebs.Iops' => root_disk_iops)
|
140
|
+
elsif root_disk_type == 'gp3'
|
141
|
+
# set default GP3 values if no valued provided
|
142
|
+
root_disk_iops = 3000 if root_disk_iops == 0
|
143
|
+
root_disk_throughput = 125 if root_disk_throughput == 0
|
144
|
+
|
145
|
+
root_disk.merge!('Ebs.Iops' => root_disk_iops)
|
146
|
+
root_disk.merge!('Ebs.Throughput' => root_disk_throughput)
|
115
147
|
end
|
116
148
|
# add the root disk as the first entry in the array of disks to create/attach
|
117
149
|
create_ebs_volume = [ root_disk ]
|
@@ -137,8 +169,11 @@ module AvstCloud
|
|
137
169
|
end
|
138
170
|
|
139
171
|
# if the additional disk is an provisioned IOPS disk set the iops value
|
140
|
-
if volume_type == 'io1'
|
172
|
+
if volume_type == 'io1' or volume_type == 'io2'
|
141
173
|
disk_hash.merge!('Ebs.Iops' => disk['volume_iops'] || 0)
|
174
|
+
elsif volume_type == 'gp3'
|
175
|
+
disk_hash.merge!('Ebs.Iops' => disk['volume_iops'] || 3000)
|
176
|
+
disk_hash.merge!('Ebs.Throughput' => disk['volume_throughput'] || 125)
|
142
177
|
end
|
143
178
|
|
144
179
|
# add this disk to the array of all disks to create/attach
|
@@ -181,26 +216,33 @@ module AvstCloud
|
|
181
216
|
logger.debug "[DONE]\n\n"
|
182
217
|
|
183
218
|
# create Elastic IP Address if required
|
184
|
-
if create_elastic_ip
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
logger.debug ("Elastic IP #{elastic_ip_address} created, attempting to allocate to server")
|
191
|
-
connect.associate_address(server.id, elastic_ip_address)
|
192
|
-
# reacquire server object as IP has, probably, changed
|
193
|
-
server = find_fog_server(server_name)
|
194
|
-
|
195
|
-
# create tag on the Elastic IP
|
196
|
-
# TODO: add ability for other tags to be defined by the user
|
197
|
-
logger.debug("Creating tags on Elastic IP Address #{elastic_ip}\n\n")
|
198
|
-
connect.tags.create(:resource_id => elastic_ip['allocationId'], :key => "Name", :value => server_name)
|
219
|
+
if create_elastic_ip
|
220
|
+
if elastic_ip_address.nil?
|
221
|
+
logger.debug("Attempting to create elastic IP address")
|
222
|
+
elastic_ip = connect.allocate_address("vpc").body
|
223
|
+
elastic_ip_address = elastic_ip['publicIp']
|
224
|
+
logger.warn "Elastic IP creation failed, proceeding with non Elastic IP\n\n" if ! elastic_ip_address
|
199
225
|
else
|
200
|
-
logger.warn
|
226
|
+
logger.warn "You have asked to create an Elastic IP and ALSO use an existing one"
|
227
|
+
logger.warn "The existing IP is avaliable and as such will be used INSTEAD of creating a new one!"
|
201
228
|
end
|
202
229
|
end
|
203
230
|
|
231
|
+
# if we have a server id and an Elastic public IP attempt to join the two togehter
|
232
|
+
if server.id and elastic_ip_address
|
233
|
+
logger.debug ("Attempting to allocate Elastic IP #{elastic_ip_address} to server")
|
234
|
+
connect.associate_address(server.id, elastic_ip_address)
|
235
|
+
# reacquire server object as IP has, probably, changed
|
236
|
+
server = find_fog_server(server_name)
|
237
|
+
|
238
|
+
# create tag on the Elastic IP
|
239
|
+
# TODO: add ability for other tags to be defined by the user
|
240
|
+
logger.debug("Creating tags on Elastic IP Address #{elastic_ip}\n\n")
|
241
|
+
connect.tags.create(:resource_id => elastic_ip['allocationId'], :key => "Name", :value => server_name)
|
242
|
+
else
|
243
|
+
logger.warn("EAllocation of Elastic IP failed, proceeding with non Elastic IP\n\n")
|
244
|
+
end
|
245
|
+
|
204
246
|
logger.debug "The server has been successfully created, to login onto the server:\n"
|
205
247
|
logger.debug "\t ssh -i #{ssh_key} #{root_user}@#{server.public_ip_address}\n"
|
206
248
|
if create_ebs_volume
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avst-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Brehovsky
|
8
8
|
- Jon Bevan
|
9
9
|
- Matthew Hope
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.2.33
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 2.2.33
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rake
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,14 +200,14 @@ dependencies:
|
|
200
200
|
requirements:
|
201
201
|
- - "~>"
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version: 1.
|
203
|
+
version: 1.13.9
|
204
204
|
type: :runtime
|
205
205
|
prerelease: false
|
206
206
|
version_requirements: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
208
|
- - "~>"
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version: 1.
|
210
|
+
version: 1.13.9
|
211
211
|
- !ruby/object:Gem::Dependency
|
212
212
|
name: signet
|
213
213
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,23 +274,23 @@ files:
|
|
274
274
|
homepage: http://www.adaptavist.com
|
275
275
|
licenses: []
|
276
276
|
metadata: {}
|
277
|
-
post_install_message:
|
277
|
+
post_install_message:
|
278
278
|
rdoc_options: []
|
279
279
|
require_paths:
|
280
280
|
- lib
|
281
281
|
required_ruby_version: !ruby/object:Gem::Requirement
|
282
282
|
requirements:
|
283
|
-
- - "
|
283
|
+
- - "~>"
|
284
284
|
- !ruby/object:Gem::Version
|
285
|
-
version:
|
285
|
+
version: 2.6.0
|
286
286
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
287
287
|
requirements:
|
288
288
|
- - ">="
|
289
289
|
- !ruby/object:Gem::Version
|
290
290
|
version: '0'
|
291
291
|
requirements: []
|
292
|
-
rubygems_version: 3.0.
|
293
|
-
signing_key:
|
292
|
+
rubygems_version: 3.0.9
|
293
|
+
signing_key:
|
294
294
|
specification_version: 4
|
295
295
|
summary: Automated creation, bootstrapping and provisioning of servers
|
296
296
|
test_files: []
|