scout-camp 0.1.1
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.
- checksums.yaml +7 -0
- data/.vimproject +81 -0
- data/LICENSE +20 -0
- data/README.md +26 -0
- data/Rakefile +70 -0
- data/VERSION +1 -0
- data/bin/scout-camp +5 -0
- data/lib/scout/aws/s3.rb +157 -0
- data/lib/scout/offsite/exceptions.rb +9 -0
- data/lib/scout/offsite/ssh.rb +175 -0
- data/lib/scout/offsite/step.rb +100 -0
- data/lib/scout/offsite/sync.rb +55 -0
- data/lib/scout/offsite.rb +3 -0
- data/lib/scout/terraform_dsl/deployment.rb +285 -0
- data/lib/scout/terraform_dsl/util.rb +100 -0
- data/lib/scout/terraform_dsl.rb +317 -0
- data/lib/scout-camp.rb +6 -0
- data/scout_commands/offsite +30 -0
- data/scout_commands/terraform/add +78 -0
- data/scout_commands/terraform/apply +31 -0
- data/scout_commands/terraform/destroy +31 -0
- data/scout_commands/terraform/list +36 -0
- data/scout_commands/terraform/remove +39 -0
- data/scout_commands/terraform/status +33 -0
- data/share/terraform/aws/bucket/main.tf +8 -0
- data/share/terraform/aws/bucket/output.tf +3 -0
- data/share/terraform/aws/bucket/variables.tf +4 -0
- data/share/terraform/aws/cluster/main.tf +66 -0
- data/share/terraform/aws/cluster/output.tf +9 -0
- data/share/terraform/aws/cluster/variables.tf +49 -0
- data/share/terraform/aws/host/locals.tf +15 -0
- data/share/terraform/aws/host/main.tf +22 -0
- data/share/terraform/aws/host/output.tf +9 -0
- data/share/terraform/aws/host/variables.tf +67 -0
- data/share/terraform/aws/lambda/main.tf +40 -0
- data/share/terraform/aws/lambda/variables.tf +23 -0
- data/share/terraform/aws/provider/data.tf +35 -0
- data/share/terraform/aws/provider/output.tf +16 -0
- data/test/scout/aws/test_s3.rb +82 -0
- data/test/scout/offsite/test_ssh.rb +15 -0
- data/test/scout/offsite/test_step.rb +33 -0
- data/test/scout/offsite/test_sync.rb +36 -0
- data/test/scout/test_terraform_dsl.rb +519 -0
- data/test/test_helper.rb +19 -0
- metadata +99 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
|
3
|
+
|
|
4
|
+
class TestTerraform < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def aws_provider_info_from_ENV
|
|
7
|
+
{:region => ENV["AWS_REGION"], :access_key => ENV["AWS_KEY"], :secret_key => ENV["AWS_SECRET"]}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _test_output_format
|
|
12
|
+
terraform = TerraformDSL.new
|
|
13
|
+
terraform.add :aws, :host,
|
|
14
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
15
|
+
|
|
16
|
+
with_tmp_file do |tmpconfig|
|
|
17
|
+
FileUtils.mkdir tmpconfig
|
|
18
|
+
terraform.config tmpconfig
|
|
19
|
+
assert File.read(tmpconfig + '/host.aws_host.outputs.tf')
|
|
20
|
+
.include?('output "aws_host_ip"')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
terraform = TerraformDSL.new
|
|
24
|
+
terraform.add :aws, :host,
|
|
25
|
+
:outputs => :all
|
|
26
|
+
|
|
27
|
+
with_tmp_file do |tmpconfig|
|
|
28
|
+
FileUtils.mkdir tmpconfig
|
|
29
|
+
terraform.config tmpconfig
|
|
30
|
+
assert File.read(tmpconfig + '/host.aws_host.outputs.tf')
|
|
31
|
+
.include?('output "aws_host_aws_instance_ip"')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
terraform = TerraformDSL.new
|
|
35
|
+
terraform.add :aws, :host,
|
|
36
|
+
:outputs => [:all]
|
|
37
|
+
|
|
38
|
+
with_tmp_file do |tmpconfig|
|
|
39
|
+
FileUtils.mkdir tmpconfig
|
|
40
|
+
terraform.config tmpconfig
|
|
41
|
+
assert File.read(tmpconfig + '/host.aws_host.outputs.tf')
|
|
42
|
+
.include?('output "aws_host_aws_instance_ip"')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
terraform = TerraformDSL.new
|
|
46
|
+
terraform.add :aws, :host,
|
|
47
|
+
:outputs => [:all, { :aws_instance_ip => :ip }]
|
|
48
|
+
|
|
49
|
+
with_tmp_file do |tmpconfig|
|
|
50
|
+
FileUtils.mkdir tmpconfig
|
|
51
|
+
terraform.config tmpconfig
|
|
52
|
+
assert File.read(tmpconfig + '/host.aws_host.outputs.tf')
|
|
53
|
+
.include?('output "aws_host_ip"')
|
|
54
|
+
assert File.read(tmpconfig + '/host.aws_host.outputs.tf')
|
|
55
|
+
.include?('output "aws_host_aws_instance_ip"')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def _test_plan
|
|
60
|
+
terraform = TerraformDSL.new
|
|
61
|
+
|
|
62
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
63
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
64
|
+
|
|
65
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
66
|
+
|
|
67
|
+
terraform.add :aws, :host, :name => 'host1',
|
|
68
|
+
:host_nametag => 'TEST-PRO-Host1',
|
|
69
|
+
:ssh_key => ssh_key,
|
|
70
|
+
:ami => provider.default_ami,
|
|
71
|
+
:instance_type => 't2.micro',
|
|
72
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
73
|
+
|
|
74
|
+
config_dir = terraform.config
|
|
75
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
76
|
+
|
|
77
|
+
begin
|
|
78
|
+
deployment.plan
|
|
79
|
+
assert true
|
|
80
|
+
rescue StandardError
|
|
81
|
+
Log.exception $!
|
|
82
|
+
assert false
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def _test_empty_deployment
|
|
87
|
+
terraform = TerraformDSL.new
|
|
88
|
+
|
|
89
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
90
|
+
ssh_key = Open.read(ssh_key_file).strip
|
|
91
|
+
|
|
92
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
93
|
+
|
|
94
|
+
config_dir = terraform.config
|
|
95
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
96
|
+
|
|
97
|
+
deployment.with_deployment do
|
|
98
|
+
assert_match "Ubuntu", deployment.element_state("module.aws_provider.data.aws_ami.ubuntu2004")
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_simple_deployment
|
|
104
|
+
terraform = TerraformDSL.new
|
|
105
|
+
|
|
106
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
107
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
108
|
+
|
|
109
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
110
|
+
|
|
111
|
+
host1 = terraform.add :aws, :host, :name => 'host1',
|
|
112
|
+
:host_nametag => 'TEST-Host1',
|
|
113
|
+
:ssh_key => ssh_key,
|
|
114
|
+
:ami => provider.default_ami,
|
|
115
|
+
:instance_type => 't2.micro',
|
|
116
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
117
|
+
|
|
118
|
+
config_dir = terraform.config
|
|
119
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
120
|
+
|
|
121
|
+
deployment.plan
|
|
122
|
+
deployment.with_deployment do
|
|
123
|
+
assert deployment.outputs.include?('host1_ip')
|
|
124
|
+
assert_equal 4, deployment.output('host1', 'ip').split('.').length
|
|
125
|
+
assert_equal 4, deployment.output(host1, 'ip').split('.').length
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def _test_simple_deployment_save_load
|
|
130
|
+
terraform = TerraformDSL.new
|
|
131
|
+
|
|
132
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
133
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
134
|
+
|
|
135
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
136
|
+
terraform.add :aws, :host, :name => 'host1',
|
|
137
|
+
:host_nametag => 'TEST-Host1',
|
|
138
|
+
:ssh_key => ssh_key,
|
|
139
|
+
:ami => provider.default_ami,
|
|
140
|
+
:instance_type => 't2.micro',
|
|
141
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
142
|
+
|
|
143
|
+
config_dir = terraform.config
|
|
144
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
145
|
+
|
|
146
|
+
deployment.with_deployment do
|
|
147
|
+
deployment.with_bundle do |tmp_file|
|
|
148
|
+
deployment2 = TerraformDSL::Deployment.load tmp_file
|
|
149
|
+
|
|
150
|
+
assert_equal deployment.provisioned_elements, deployment2.provisioned_elements
|
|
151
|
+
|
|
152
|
+
deployment2.destroy
|
|
153
|
+
deployment.refresh
|
|
154
|
+
|
|
155
|
+
assert deployment2.provisioned_elements.empty?
|
|
156
|
+
assert deployment.provisioned_elements.reject {|e| e.include? '.data.' }.empty?
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def _test_double_deployment
|
|
162
|
+
terraform = TerraformDSL.new
|
|
163
|
+
|
|
164
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
165
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
166
|
+
|
|
167
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
168
|
+
|
|
169
|
+
terraform.add :aws, :host, :name => 'host1',
|
|
170
|
+
:host_nametag => 'TEST-PRO-Host1',
|
|
171
|
+
:ssh_key => ssh_key,
|
|
172
|
+
:ami => provider.default_ami,
|
|
173
|
+
:instance_type => 'c5.metal',
|
|
174
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
175
|
+
|
|
176
|
+
host2 = terraform.add :aws, :host, :name => 'host2',
|
|
177
|
+
:host_nametag => 'TEST-PRO-Host2',
|
|
178
|
+
:ssh_key => ssh_key,
|
|
179
|
+
:ami => provider.default_ami,
|
|
180
|
+
:instance_type => 'c5.metal',
|
|
181
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
182
|
+
|
|
183
|
+
config_dir = terraform.config
|
|
184
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
185
|
+
|
|
186
|
+
deployment.with_deployment do
|
|
187
|
+
assert deployment.outputs.include?('host1_ip')
|
|
188
|
+
assert deployment.outputs.include?('host2_ip')
|
|
189
|
+
assert_equal 4, deployment.output('host2', 'ip').split('.').length
|
|
190
|
+
assert_equal 4, deployment.output(host2, 'ip').split('.').length
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def _test_incremental_deployment
|
|
195
|
+
terraform = TerraformDSL.new
|
|
196
|
+
|
|
197
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
198
|
+
|
|
199
|
+
config_dir = terraform.config
|
|
200
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
201
|
+
|
|
202
|
+
begin
|
|
203
|
+
deployment.apply
|
|
204
|
+
|
|
205
|
+
terraform.add :aws, :host, :name => 'host1',
|
|
206
|
+
:host_nametag => 'TEST-PRO-Host1',
|
|
207
|
+
:ami => provider.default_ami,
|
|
208
|
+
:instance_type => 't2.micro',
|
|
209
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
210
|
+
|
|
211
|
+
terraform.config config_dir
|
|
212
|
+
deployment.update
|
|
213
|
+
|
|
214
|
+
assert deployment.outputs.include?('host1_ip')
|
|
215
|
+
assert_equal 4, deployment.output('host1', 'ip').split('.').length
|
|
216
|
+
|
|
217
|
+
host2 = terraform.add :aws, :host, :name => 'host2',
|
|
218
|
+
:host_nametag => 'TEST-PRO-Host2',
|
|
219
|
+
:ami => provider.default_ami,
|
|
220
|
+
:instance_type => 't2.micro',
|
|
221
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
222
|
+
|
|
223
|
+
terraform.config config_dir
|
|
224
|
+
deployment.update
|
|
225
|
+
|
|
226
|
+
assert deployment.outputs.include?('host1_ip')
|
|
227
|
+
assert deployment.outputs.include?('host2_ip')
|
|
228
|
+
assert_equal 4, deployment.output('host2', 'ip').split('.').length
|
|
229
|
+
assert_equal 4, deployment.output(host2, 'ip').split('.').length
|
|
230
|
+
ensure
|
|
231
|
+
deployment.destroy
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def _test_simple_host_register
|
|
236
|
+
terraform = TerraformDSL.new
|
|
237
|
+
|
|
238
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
239
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
240
|
+
|
|
241
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
242
|
+
|
|
243
|
+
host1 = terraform.add :aws, :host, :name => 'host1',
|
|
244
|
+
:host_nametag => 'TEST-PRO-Host_1',
|
|
245
|
+
:ssh_key => ssh_key,
|
|
246
|
+
:ami => provider.default_ami,
|
|
247
|
+
:instance_type => 'c5.metal',
|
|
248
|
+
:outputs => :all
|
|
249
|
+
|
|
250
|
+
config_dir = terraform.config
|
|
251
|
+
|
|
252
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
253
|
+
|
|
254
|
+
deployment.plan
|
|
255
|
+
|
|
256
|
+
deployment.with_deployment do
|
|
257
|
+
ip = deployment.output host1, :aws_instance_ip
|
|
258
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip} whoami`.strip
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def _test_cluster_register
|
|
263
|
+
terraform = TerraformDSL.new
|
|
264
|
+
|
|
265
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
266
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
267
|
+
|
|
268
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
269
|
+
|
|
270
|
+
cluster = terraform.add :aws, :cluster
|
|
271
|
+
|
|
272
|
+
host1 = terraform.add :aws, :host, :name => 'host',
|
|
273
|
+
:host_nametag => 'TEST-PRO-Host',
|
|
274
|
+
:ssh_key => ssh_key,
|
|
275
|
+
:ami => provider.default_ami,
|
|
276
|
+
:subnet_id => cluster.aws_subnet_id,
|
|
277
|
+
:vpc_security_group_ids => [cluster.aws_security_group_id],
|
|
278
|
+
:private_ip => '10.0.0.5',
|
|
279
|
+
:instance_type => 'c5.metal',
|
|
280
|
+
:outputs => :all
|
|
281
|
+
|
|
282
|
+
configure1 = terraform.add :opennebula, :configure, :name => 'configure',
|
|
283
|
+
:ip => host1.aws_instance_ip,
|
|
284
|
+
:file => File.join(TerraformDSL::ANSIBLE_DIR, 'aws.yml')
|
|
285
|
+
|
|
286
|
+
config_dir = terraform.config
|
|
287
|
+
|
|
288
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
289
|
+
|
|
290
|
+
deployment.with_deployment do
|
|
291
|
+
ip = deployment.output host1, :aws_instance_ip
|
|
292
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip} whoami`.strip
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def _test_multiple_configure
|
|
297
|
+
terraform = TerraformDSL.new
|
|
298
|
+
|
|
299
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
300
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
301
|
+
|
|
302
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
303
|
+
|
|
304
|
+
host1 = terraform.add :aws, :host, :name => 'host1',
|
|
305
|
+
:host_nametag => 'TEST-PRO-Host_1',
|
|
306
|
+
:ssh_key => ssh_key,
|
|
307
|
+
:ami => provider.default_ami,
|
|
308
|
+
:instance_type => 'c5.metal',
|
|
309
|
+
:outputs => :all
|
|
310
|
+
|
|
311
|
+
host2 = terraform.add :aws, :host, :name => 'host2',
|
|
312
|
+
:host_nametag => 'TEST-PRO-Host_2',
|
|
313
|
+
:ssh_key => ssh_key,
|
|
314
|
+
:ami => provider.default_ami,
|
|
315
|
+
:instance_type => 'c5.metal',
|
|
316
|
+
:outputs => :all
|
|
317
|
+
|
|
318
|
+
config_dir = terraform.config
|
|
319
|
+
|
|
320
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
321
|
+
|
|
322
|
+
deployment.with_deployment do
|
|
323
|
+
ip1 = deployment.output host1, :aws_instance_ip
|
|
324
|
+
ip2 = deployment.output host2, :aws_instance_ip
|
|
325
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip1} whoami`.strip
|
|
326
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip2} whoami`.strip
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def _test_multiple_register
|
|
331
|
+
terraform = TerraformDSL.new
|
|
332
|
+
|
|
333
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
334
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
335
|
+
|
|
336
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
337
|
+
|
|
338
|
+
one_provider terraform
|
|
339
|
+
|
|
340
|
+
host1 = terraform.add :aws, :host, :name => 'host1',
|
|
341
|
+
:host_nametag => 'TEST-PRO-Host_1',
|
|
342
|
+
:ssh_key => ssh_key,
|
|
343
|
+
:ami => provider.default_ami,
|
|
344
|
+
:instance_type => 'c5.metal',
|
|
345
|
+
:outputs => :all
|
|
346
|
+
|
|
347
|
+
host2 = terraform.add :aws, :host, :name => 'host2',
|
|
348
|
+
:host_nametag => 'TEST-PRO-Host_2',
|
|
349
|
+
:ssh_key => ssh_key,
|
|
350
|
+
:ami => provider.default_ami,
|
|
351
|
+
:instance_type => 'c5.metal',
|
|
352
|
+
:outputs => :all
|
|
353
|
+
|
|
354
|
+
configure = terraform.add :opennebula, :configure,
|
|
355
|
+
:ip_list => [host1.aws_instance_ip, host2.aws_instance_ip],
|
|
356
|
+
:file => File.join(TerraformDSL::ANSIBLE_DIR, 'aws.yml')
|
|
357
|
+
|
|
358
|
+
terraform.add :opennebula, :register_host,
|
|
359
|
+
:ip_list => [host1.aws_instance_ip, host2.aws_instance_ip],
|
|
360
|
+
:depends_on => [configure],
|
|
361
|
+
:deployment_id => 'one-provision-deployment_test_multiple_register',
|
|
362
|
+
:virtualization_type => 'kvm'
|
|
363
|
+
|
|
364
|
+
config_dir = terraform.config
|
|
365
|
+
|
|
366
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
367
|
+
|
|
368
|
+
deployment.with_deployment do
|
|
369
|
+
ip1 = deployment.output host1, :aws_instance_ip
|
|
370
|
+
ip2 = deployment.output host2, :aws_instance_ip
|
|
371
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip1} whoami`.strip
|
|
372
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip2} whoami`.strip
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def _test_datastore_registry
|
|
377
|
+
terraform = TerraformDSL.new
|
|
378
|
+
|
|
379
|
+
deployment_id = "one-provision-deployment-#{__method__}"
|
|
380
|
+
|
|
381
|
+
one_provider terraform
|
|
382
|
+
|
|
383
|
+
cluster = terraform.add :opennebula, :register_cluster,
|
|
384
|
+
:deployment_id => deployment_id
|
|
385
|
+
|
|
386
|
+
terraform.add :opennebula, :register_datastores,
|
|
387
|
+
:cluster_ids => [cluster.cluster_id],
|
|
388
|
+
:deployment_id => deployment_id
|
|
389
|
+
|
|
390
|
+
terraform.add :opennebula, :register_network,
|
|
391
|
+
:cluster_ids => [cluster.cluster_id],
|
|
392
|
+
:deployment_id => deployment_id
|
|
393
|
+
|
|
394
|
+
config_dir = terraform.config
|
|
395
|
+
|
|
396
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
397
|
+
|
|
398
|
+
deployment.with_deployment do
|
|
399
|
+
assert true
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def _test_wrong_aws_key
|
|
404
|
+
terraform = TerraformDSL.new
|
|
405
|
+
|
|
406
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
407
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
408
|
+
|
|
409
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
410
|
+
|
|
411
|
+
terraform.add :aws, :host, :name => 'host1',
|
|
412
|
+
:host_nametag => 'TEST-PRO-Host1',
|
|
413
|
+
:ssh_key => ssh_key,
|
|
414
|
+
:ami => provider.default_ami,
|
|
415
|
+
:instance_type => 't2.micro',
|
|
416
|
+
:outputs => { :aws_instance_ip => :ip }
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
config_dir = terraform.config
|
|
420
|
+
|
|
421
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
422
|
+
|
|
423
|
+
assert_raise TerraformDSL::Deployment::TerraformException do
|
|
424
|
+
deployment.plan
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def _test_wrong_one_login
|
|
429
|
+
terraform = TerraformDSL.new
|
|
430
|
+
|
|
431
|
+
deployment_id = "one-provision-deployment-#{__method__}"
|
|
432
|
+
|
|
433
|
+
terraform.provider :opennebula,
|
|
434
|
+
:source => 'OpenNebula/opennebula',
|
|
435
|
+
:endpoint => one_provider_info_from_ENV["endpoint"],
|
|
436
|
+
:username => 'wrong_user',
|
|
437
|
+
:password => 'wrong_password'
|
|
438
|
+
|
|
439
|
+
cluster = terraform.add :opennebula, :register_cluster,
|
|
440
|
+
:deployment_id => deployment_id
|
|
441
|
+
|
|
442
|
+
terraform.add :opennebula, :register_datastores,
|
|
443
|
+
:cluster_ids => [cluster.cluster_id],
|
|
444
|
+
:deployment_id => deployment_id
|
|
445
|
+
|
|
446
|
+
config_dir = terraform.config
|
|
447
|
+
|
|
448
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
449
|
+
|
|
450
|
+
assert_raise TerraformDSL::Deployment::TerraformException do
|
|
451
|
+
deployment.plan
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
def _test_cluster_complete_registry
|
|
456
|
+
terraform = TerraformDSL.new
|
|
457
|
+
|
|
458
|
+
deployment_id = "one-provision-deployment-#{__method__}"
|
|
459
|
+
|
|
460
|
+
ssh_key_file = "#{Dir.home}/.ssh/id_rsa.pub"
|
|
461
|
+
ssh_key = File.read(ssh_key_file).strip
|
|
462
|
+
|
|
463
|
+
provider = terraform.provider :aws, aws_provider_info_from_ENV
|
|
464
|
+
|
|
465
|
+
one_provider terraform
|
|
466
|
+
|
|
467
|
+
host1 = terraform.add :aws, :host, :name => 'host1',
|
|
468
|
+
:host_nametag => 'TEST-PRO-Host_1',
|
|
469
|
+
:ssh_key => ssh_key,
|
|
470
|
+
:ami => provider.default_ami,
|
|
471
|
+
:instance_type => 'c5.metal',
|
|
472
|
+
:outputs => :all
|
|
473
|
+
|
|
474
|
+
host2 = terraform.add :aws, :host, :name => 'host2',
|
|
475
|
+
:host_nametag => 'TEST-PRO-Host_2',
|
|
476
|
+
:ssh_key => ssh_key,
|
|
477
|
+
:ami => provider.default_ami,
|
|
478
|
+
:instance_type => 'c5.metal',
|
|
479
|
+
:outputs => :all
|
|
480
|
+
|
|
481
|
+
configure = terraform.add :opennebula, :configure,
|
|
482
|
+
:ip_list => [host1.aws_instance_ip, host2.aws_instance_ip],
|
|
483
|
+
:file => File.join(TerraformDSL::ANSIBLE_DIR, 'aws.yml')
|
|
484
|
+
|
|
485
|
+
cluster = terraform.add :opennebula, :register_cluster,
|
|
486
|
+
:deployment_id => deployment_id
|
|
487
|
+
|
|
488
|
+
terraform.add :opennebula, :register_host,
|
|
489
|
+
:ip_list => [host1.aws_instance_ip, host2.aws_instance_ip],
|
|
490
|
+
:depends_on => [configure],
|
|
491
|
+
:cluster_id => cluster.cluster_id,
|
|
492
|
+
:deployment_id => deployment_id,
|
|
493
|
+
:virtualization_type => 'kvm'
|
|
494
|
+
|
|
495
|
+
terraform.add :opennebula, :register_datastores,
|
|
496
|
+
:cluster_ids => [cluster.cluster_id],
|
|
497
|
+
:deployment_id => deployment_id
|
|
498
|
+
|
|
499
|
+
network = terraform.add :opennebula, :register_network,
|
|
500
|
+
:cluster_ids => [cluster.cluster_id],
|
|
501
|
+
:deployment_id => deployment_id
|
|
502
|
+
|
|
503
|
+
# terraform.add :opennebula, :register_ip,
|
|
504
|
+
# :network_id => [network.public_id],
|
|
505
|
+
# :ipam => provider.ipam
|
|
506
|
+
#
|
|
507
|
+
config_dir = terraform.config
|
|
508
|
+
|
|
509
|
+
deployment = TerraformDSL::Deployment.new config_dir
|
|
510
|
+
deployment.plan
|
|
511
|
+
|
|
512
|
+
deployment.with_deployment do
|
|
513
|
+
ip1 = deployment.output host1, :aws_instance_ip
|
|
514
|
+
ip2 = deployment.output host2, :aws_instance_ip
|
|
515
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip1} whoami`.strip
|
|
516
|
+
assert_equal 'ubuntu', `ssh ubuntu@#{ip2} whoami`.strip
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'tempfile'
|
|
3
|
+
require 'scout/log'
|
|
4
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
|
5
|
+
$LOAD_PATH.unshift(__dir__)
|
|
6
|
+
|
|
7
|
+
class Test::Unit::TestCase
|
|
8
|
+
|
|
9
|
+
def with_tmp_file
|
|
10
|
+
name = 'test_file_terraform_' + rand(100000).to_s
|
|
11
|
+
file = File.join('/tmp', name)
|
|
12
|
+
begin
|
|
13
|
+
yield file
|
|
14
|
+
ensure
|
|
15
|
+
FileUtils.rm_rf file
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: scout-camp
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Miguel Vazquez
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2025-03-19 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: scout-essentials
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
description: Functionalities to deploy and use scouts in remote servers like AWS
|
|
27
|
+
email: mikisvaz@gmail.com
|
|
28
|
+
executables:
|
|
29
|
+
- scout-camp
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files:
|
|
32
|
+
- LICENSE
|
|
33
|
+
- README.md
|
|
34
|
+
files:
|
|
35
|
+
- ".vimproject"
|
|
36
|
+
- LICENSE
|
|
37
|
+
- README.md
|
|
38
|
+
- Rakefile
|
|
39
|
+
- VERSION
|
|
40
|
+
- bin/scout-camp
|
|
41
|
+
- lib/scout-camp.rb
|
|
42
|
+
- lib/scout/aws/s3.rb
|
|
43
|
+
- lib/scout/offsite.rb
|
|
44
|
+
- lib/scout/offsite/exceptions.rb
|
|
45
|
+
- lib/scout/offsite/ssh.rb
|
|
46
|
+
- lib/scout/offsite/step.rb
|
|
47
|
+
- lib/scout/offsite/sync.rb
|
|
48
|
+
- lib/scout/terraform_dsl.rb
|
|
49
|
+
- lib/scout/terraform_dsl/deployment.rb
|
|
50
|
+
- lib/scout/terraform_dsl/util.rb
|
|
51
|
+
- scout_commands/offsite
|
|
52
|
+
- scout_commands/terraform/add
|
|
53
|
+
- scout_commands/terraform/apply
|
|
54
|
+
- scout_commands/terraform/destroy
|
|
55
|
+
- scout_commands/terraform/list
|
|
56
|
+
- scout_commands/terraform/remove
|
|
57
|
+
- scout_commands/terraform/status
|
|
58
|
+
- share/terraform/aws/bucket/main.tf
|
|
59
|
+
- share/terraform/aws/bucket/output.tf
|
|
60
|
+
- share/terraform/aws/bucket/variables.tf
|
|
61
|
+
- share/terraform/aws/cluster/main.tf
|
|
62
|
+
- share/terraform/aws/cluster/output.tf
|
|
63
|
+
- share/terraform/aws/cluster/variables.tf
|
|
64
|
+
- share/terraform/aws/host/locals.tf
|
|
65
|
+
- share/terraform/aws/host/main.tf
|
|
66
|
+
- share/terraform/aws/host/output.tf
|
|
67
|
+
- share/terraform/aws/host/variables.tf
|
|
68
|
+
- share/terraform/aws/lambda/main.tf
|
|
69
|
+
- share/terraform/aws/lambda/variables.tf
|
|
70
|
+
- share/terraform/aws/provider/data.tf
|
|
71
|
+
- share/terraform/aws/provider/output.tf
|
|
72
|
+
- test/scout/aws/test_s3.rb
|
|
73
|
+
- test/scout/offsite/test_ssh.rb
|
|
74
|
+
- test/scout/offsite/test_step.rb
|
|
75
|
+
- test/scout/offsite/test_sync.rb
|
|
76
|
+
- test/scout/test_terraform_dsl.rb
|
|
77
|
+
- test/test_helper.rb
|
|
78
|
+
homepage: http://github.com/mikisvaz/scout-camp
|
|
79
|
+
licenses:
|
|
80
|
+
- MIT
|
|
81
|
+
metadata: {}
|
|
82
|
+
rdoc_options: []
|
|
83
|
+
require_paths:
|
|
84
|
+
- lib
|
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
requirements: []
|
|
96
|
+
rubygems_version: 3.6.5
|
|
97
|
+
specification_version: 4
|
|
98
|
+
summary: Deploy you scouts
|
|
99
|
+
test_files: []
|