kitchen-ec2 0.9.5 → 0.10.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/README.md +49 -25
- data/Rakefile +2 -13
- data/data/amis.json +29 -10
- data/kitchen-ec2.gemspec +1 -3
- data/lib/kitchen/driver/aws/instance_generator.rb +0 -1
- data/lib/kitchen/driver/ec2.rb +87 -5
- data/lib/kitchen/driver/ec2_version.rb +1 -1
- data/spec/kitchen/driver/ec2_spec.rb +93 -11
- metadata +10 -33
- data/.cane +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1afe405e2b2540e860aa776f26f53df005aa9fb
|
4
|
+
data.tar.gz: 0893be9f82b85a878670574ec6e4edd36f2b979f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c5483cdbb6079926207e3c1291191c647512bc0076748bf29ea8724f83e84ab7515f2c738e12cdeedc69024485664e31d8d4a5d88e95e2da5528643129b2003
|
7
|
+
data.tar.gz: 4c11b5f222aa4c6502ac8a2c0733548c959eac5267047e68a75fd4e445a17c2f33e1b405f19a030273126a65dca53bace16e626b4d0664ac4af6ec95bf68f2fb
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,20 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.10.0 / TBD
|
2
|
+
|
3
|
+
### Bug Fixes
|
4
|
+
|
5
|
+
### New Features
|
6
|
+
|
7
|
+
* Pull Request [#150][]: Added support for managing Windows hosts in AWS
|
8
|
+
* Updated `amis.json` to include AMIs for Windows Server 2008 and 2012R2.
|
9
|
+
* Add default user data which enables winrm. See `ec2.rb` for the exact user data that is uploaded.
|
10
|
+
* Default user data will add a non-`administrator` user to the Administrator group if `username` and `password` transport options are specified.
|
11
|
+
* EC2 will automatically generate the `administrator` user password if it is not specified as `password` transport options. This will be stored and used for further kitchen commands.
|
12
|
+
* Unfortunately this cannot be passed to the RDP client initiated by `kitchen login`. Look at `.kitchen/<name>.yml` for the password in this case.
|
13
|
+
* A HUGE thanks to [@zl4bv][] and [@afiune][] for the majority of the work on these changes!
|
14
|
+
|
15
|
+
### Improvements
|
16
|
+
|
17
|
+
## 0.9.5 / 2015-06-05
|
2
18
|
|
3
19
|
### Bug Fixes
|
4
20
|
|
@@ -175,6 +191,7 @@
|
|
175
191
|
[#131]: https://github.com/test-kitchen/kitchen-ec2/issues/131
|
176
192
|
[#140]: https://github.com/test-kitchen/kitchen-ec2/issues/140
|
177
193
|
[#142]: https://github.com/test-kitchen/kitchen-ec2/issues/142
|
194
|
+
[#150]: https://github.com/test-kitchen/kitchen-ec2/issues/150
|
178
195
|
[#151]: https://github.com/test-kitchen/kitchen-ec2/issues/151
|
179
196
|
[@Atalanta]: https://github.com/Atalanta
|
180
197
|
[@Igorshp]: https://github.com/Igorshp
|
@@ -196,10 +213,12 @@
|
|
196
213
|
[@mattray]: https://github.com/mattray
|
197
214
|
[@mumoshu]: https://github.com/mumoshu
|
198
215
|
[@nicgrayson]: https://github.com/nicgrayson
|
216
|
+
[@afiune]: https://github.com/afiune
|
199
217
|
[@scarolan]: https://github.com/scarolan
|
200
218
|
[@sebbrandt87]: https://github.com/sebbrandt87
|
201
219
|
[@sethvargo]: https://github.com/sethvargo
|
202
220
|
[@someara]: https://github.com/someara
|
203
221
|
[@spheromak]: https://github.com/spheromak
|
204
222
|
[@tiwilliam]: https://github.com/tiwilliam
|
205
|
-
[@tyler-ball]: https://github.com/tyler-ball
|
223
|
+
[@tyler-ball]: https://github.com/tyler-ball
|
224
|
+
[@zl4bv]: https://github.com/zl4bv
|
data/README.md
CHANGED
@@ -21,8 +21,13 @@ Please read the [Driver usage][driver_usage] page for more details.
|
|
21
21
|
## Default Configuration
|
22
22
|
|
23
23
|
This driver can determine AMI and username login for a select number of
|
24
|
-
platforms in each region.
|
25
|
-
|
24
|
+
platforms in each region.
|
25
|
+
|
26
|
+
For Windows instances the generated Administrator password is fetched
|
27
|
+
automatically from Amazon EC2 with the same private key as we use for
|
28
|
+
SSH logins to Linux.
|
29
|
+
|
30
|
+
Currently, the following platform names are supported:
|
26
31
|
|
27
32
|
```ruby
|
28
33
|
---
|
@@ -35,6 +40,8 @@ platforms:
|
|
35
40
|
- name: ubuntu-14.04
|
36
41
|
- name: centos-6.4
|
37
42
|
- name: debian-7.1.0
|
43
|
+
- name: windows-2012r2
|
44
|
+
- name: windows-2008r2
|
38
45
|
```
|
39
46
|
|
40
47
|
This will effectively generate a configuration similar to:
|
@@ -45,17 +52,21 @@ platforms:
|
|
45
52
|
- name: ubuntu-10.04
|
46
53
|
driver:
|
47
54
|
image_id: ami-1ab3ce73
|
48
|
-
|
49
|
-
- name: ubuntu-12.04
|
50
|
-
driver:
|
51
|
-
image_id: ami-2f115c46
|
55
|
+
transport:
|
52
56
|
username: ubuntu
|
53
57
|
# ...
|
54
58
|
- name: centos-6.4
|
55
59
|
driver:
|
56
60
|
image_id: ami-bf5021d6
|
61
|
+
transport:
|
57
62
|
username: root
|
58
63
|
# ...
|
64
|
+
- name: windows-2012r2
|
65
|
+
driver:
|
66
|
+
image_id: ami-28bc7428
|
67
|
+
transport:
|
68
|
+
username: administrator
|
69
|
+
# ...
|
59
70
|
```
|
60
71
|
|
61
72
|
For specific default values, please consult [amis.json][amis_json].
|
@@ -178,14 +189,18 @@ The Hash of EC tag name/value pairs which will be applied to the instance.
|
|
178
189
|
|
179
190
|
The default is `{ "created-by" => "test-kitchen" }`.
|
180
191
|
|
181
|
-
###
|
192
|
+
### user\_data
|
182
193
|
|
183
194
|
The user_data script or the path to a script to feed the instance.
|
184
195
|
Use bash to install dependencies or download artifacts before chef runs.
|
185
196
|
This is just for some cases. If you can do the stuff with chef, then do it with
|
186
197
|
chef!
|
187
198
|
|
188
|
-
|
199
|
+
On linux instances the default is unset, or `nil`.
|
200
|
+
|
201
|
+
On Windows instances we specify a default that enables winrm and
|
202
|
+
adds a non-administrator user specified in the `username` transport
|
203
|
+
options to the Administrator's User Group.
|
189
204
|
|
190
205
|
### iam\_profile\_name
|
191
206
|
|
@@ -232,10 +247,10 @@ name of your ebs device, for example: `/dev/sda1`
|
|
232
247
|
A list of block device mappings for the machine. An example of all available keys looks like:
|
233
248
|
```yaml
|
234
249
|
block_device_mappings:
|
235
|
-
- ebs_device_name: /dev/
|
250
|
+
- ebs_device_name: /dev/sda
|
236
251
|
ebs_volume_size: 20
|
237
252
|
ebs_delete_on_termination: true
|
238
|
-
- ebs_device_name: /dev/
|
253
|
+
- ebs_device_name: /dev/sdb
|
239
254
|
ebs_volume_type: gp2
|
240
255
|
ebs_virtual_name: test
|
241
256
|
ebs_volume_size: 15
|
@@ -361,21 +376,14 @@ driver:
|
|
361
376
|
name: ec2
|
362
377
|
aws_ssh_key_id: id_rsa-aws
|
363
378
|
security_group_ids: ["sg-1a2b3c4d"]
|
364
|
-
region: us-
|
379
|
+
region: us-west-2
|
365
380
|
availability_zone: b
|
366
381
|
require_chef_omnibus: true
|
367
|
-
subnet_id: subnet-
|
382
|
+
subnet_id: subnet-6e5d4c3b
|
368
383
|
iam_profile_name: chef-client
|
369
|
-
instance_type:
|
384
|
+
instance_type: m3.medium
|
370
385
|
associate_public_ip: true
|
371
|
-
private_ip_address: 10.0.0.27
|
372
386
|
interface: dns
|
373
|
-
block_device_mappings:
|
374
|
-
- ebs_device_name: /dev/sda0
|
375
|
-
ebs_volume_type: gp2
|
376
|
-
ebs_virtual_name: test
|
377
|
-
ebs_volume_size: 15
|
378
|
-
ebs_delete_on_termination: true
|
379
387
|
|
380
388
|
transport:
|
381
389
|
ssh_key: /path/to/id_rsa-aws
|
@@ -385,13 +393,29 @@ transport:
|
|
385
393
|
|
386
394
|
platforms:
|
387
395
|
- name: ubuntu-12.04
|
396
|
+
- name: centos-6.4
|
397
|
+
- name: ubuntu-15.04
|
388
398
|
driver:
|
389
|
-
image_id: ami-
|
390
|
-
|
391
|
-
|
399
|
+
image_id: ami-83211eb3
|
400
|
+
block_device_mappings:
|
401
|
+
- ebs_device_name: /dev/sda1
|
402
|
+
ebs_volume_type: standard
|
403
|
+
ebs_virtual_name: test
|
404
|
+
ebs_volume_size: 15
|
405
|
+
ebs_delete_on_termination: true
|
406
|
+
- name: centos-7
|
392
407
|
driver:
|
393
|
-
image_id: ami-
|
394
|
-
|
408
|
+
image_id: ami-c7d092f7
|
409
|
+
block_device_mappings:
|
410
|
+
- ebs_device_name: /dev/sdb
|
411
|
+
ebs_volume_type: gp2
|
412
|
+
ebs_virtual_name: test
|
413
|
+
ebs_volume_size: 8
|
414
|
+
ebs_delete_on_termination: true
|
415
|
+
transport:
|
416
|
+
username: centos
|
417
|
+
- name: windows-2012r2
|
418
|
+
- name: windows-2008r2
|
395
419
|
|
396
420
|
suites:
|
397
421
|
# ...
|
data/Rakefile
CHANGED
@@ -19,19 +19,8 @@ RuboCop::RakeTask.new(:style) do |task|
|
|
19
19
|
task.options << "--display-cop-names"
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
desc "Run cane to check quality metrics"
|
25
|
-
Cane::RakeTask.new do |cane|
|
26
|
-
cane.canefile = "./.cane"
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "Run all quality tasks"
|
30
|
-
task :quality => [:cane, :style, :stats]
|
31
|
-
else
|
32
|
-
desc "Run all quality tasks"
|
33
|
-
task :quality => [:style, :stats]
|
34
|
-
end
|
22
|
+
desc "Run all quality tasks"
|
23
|
+
task :quality => [:style, :stats]
|
35
24
|
|
36
25
|
require "yard"
|
37
26
|
YARD::Rake::YardocTask.new
|
data/data/amis.json
CHANGED
@@ -8,7 +8,9 @@
|
|
8
8
|
"ubuntu-13.10": "ami-45f1a744",
|
9
9
|
"ubuntu-14.04": "ami-955c0c94",
|
10
10
|
"centos-6.4": "ami-9ffa709e",
|
11
|
-
"debian-7.1.0": "ami-f1f064f0"
|
11
|
+
"debian-7.1.0": "ami-f1f064f0",
|
12
|
+
"windows-2012r2": "ami-28bc7428",
|
13
|
+
"windows-2008r2": "ami-5ace065a"
|
12
14
|
},
|
13
15
|
"ap-southeast-1": {
|
14
16
|
"ubuntu-10.04": "ami-34713866",
|
@@ -18,7 +20,9 @@
|
|
18
20
|
"ubuntu-13.10": "ami-02e6b850",
|
19
21
|
"ubuntu-14.04": "ami-9a7c25c8",
|
20
22
|
"centos-6.4": "ami-46f5bb14",
|
21
|
-
"debian-7.1.0": "ami-fe8ac3ac"
|
23
|
+
"debian-7.1.0": "ami-fe8ac3ac",
|
24
|
+
"windows-2012r2": "ami-062e1054",
|
25
|
+
"windows-2008r2": "ami-30291762"
|
22
26
|
},
|
23
27
|
"ap-southeast-2": {
|
24
28
|
"ubuntu-10.04": "ami-2f009315",
|
@@ -28,7 +32,9 @@
|
|
28
32
|
"ubuntu-13.10": "ami-e54423df",
|
29
33
|
"ubuntu-14.04": "ami-f3b1d6c9",
|
30
34
|
"centos-6.4": "ami-9352c1a9",
|
31
|
-
"debian-7.1.0": "ami-4e099a74"
|
35
|
+
"debian-7.1.0": "ami-4e099a74",
|
36
|
+
"windows-2012r2": "ami-6be19e51",
|
37
|
+
"windows-2008r2": "ami-fdd8a7c7"
|
32
38
|
},
|
33
39
|
"eu-west-1": {
|
34
40
|
"ubuntu-10.04": "ami-bbadb0cf",
|
@@ -38,7 +44,9 @@
|
|
38
44
|
"ubuntu-13.10": "ami-39eb3f4e",
|
39
45
|
"ubuntu-14.04": "ami-c112c5b6",
|
40
46
|
"centos-6.4": "ami-75190b01",
|
41
|
-
"debian-7.1.0": "ami-954559e1"
|
47
|
+
"debian-7.1.0": "ami-954559e1",
|
48
|
+
"windows-2012r2": "ami-1387ed64",
|
49
|
+
"windows-2008r2": "ami-1b97fd6c"
|
42
50
|
},
|
43
51
|
"sa-east-1": {
|
44
52
|
"ubuntu-10.04": "ami-962c898b",
|
@@ -48,7 +56,9 @@
|
|
48
56
|
"ubuntu-13.10": "ami-076cc21a",
|
49
57
|
"ubuntu-14.04": "ami-052b8518",
|
50
58
|
"centos-6.4": "ami-a665c0bb",
|
51
|
-
"debian-7.1.0": "ami-b03590ad"
|
59
|
+
"debian-7.1.0": "ami-b03590ad",
|
60
|
+
"windows-2012r2": "ami-7929ae64",
|
61
|
+
"windows-2008r2": "ami-9331b68e"
|
52
62
|
},
|
53
63
|
"us-east-1": {
|
54
64
|
"ubuntu-10.04": "ami-1ab3ce73",
|
@@ -58,7 +68,9 @@
|
|
58
68
|
"ubuntu-13.10": "ami-a65393ce",
|
59
69
|
"ubuntu-14.04": "ami-4a915c22",
|
60
70
|
"centos-6.4": "ami-bf5021d6",
|
61
|
-
"debian-7.1.0": "ami-50d9a439"
|
71
|
+
"debian-7.1.0": "ami-50d9a439",
|
72
|
+
"windows-2012r2": "ami-c01102a8",
|
73
|
+
"windows-2008r2": "ami-c8c0d3a0"
|
62
74
|
},
|
63
75
|
"us-west-1": {
|
64
76
|
"ubuntu-10.04": "ami-848ba2c1",
|
@@ -68,7 +80,9 @@
|
|
68
80
|
"ubuntu-13.10": "ami-bb2a2afe",
|
69
81
|
"ubuntu-14.04": "ami-d99a9a9c",
|
70
82
|
"centos-6.4": "ami-5d456c18",
|
71
|
-
"debian-7.1.0": "ami-1a9bb25f"
|
83
|
+
"debian-7.1.0": "ami-1a9bb25f",
|
84
|
+
"windows-2012r2": "ami-830ee0c7",
|
85
|
+
"windows-2008r2": "ami-af04eaeb"
|
72
86
|
},
|
73
87
|
"us-west-2": {
|
74
88
|
"ubuntu-10.04": "ami-f19407c1",
|
@@ -78,7 +92,9 @@
|
|
78
92
|
"ubuntu-13.10": "ami-c18ff1f1",
|
79
93
|
"ubuntu-14.04": "ami-b7720b87",
|
80
94
|
"centos-6.4": "ami-b3bf2f83",
|
81
|
-
"debian-7.1.0": "ami-158a1925"
|
95
|
+
"debian-7.1.0": "ami-158a1925",
|
96
|
+
"windows-2012r2": "ami-c30a39f3",
|
97
|
+
"windows-2008r2": "ami-adf8cb9d"
|
82
98
|
}
|
83
99
|
},
|
84
100
|
"usernames": {
|
@@ -89,11 +105,14 @@
|
|
89
105
|
"ubuntu-13.10": "ubuntu",
|
90
106
|
"ubuntu-14.04": "ubuntu",
|
91
107
|
"centos-6.4": "root",
|
92
|
-
"debian-7.1.0": "admin"
|
108
|
+
"debian-7.1.0": "admin",
|
109
|
+
"windows-2008r2": "administrator",
|
110
|
+
"windows-2012r2": "administrator"
|
93
111
|
},
|
94
112
|
"references": {
|
95
113
|
"ubuntu": "http://uec-images.ubuntu.com/query/",
|
96
114
|
"debian": "https://wiki.debian.org/Cloud/AmazonEC2Image",
|
97
|
-
"centos": "http://wiki.centos.org/Cloud/AWS"
|
115
|
+
"centos": "http://wiki.centos.org/Cloud/AWS",
|
116
|
+
"windows": "http://aws.amazon.com/windows/"
|
98
117
|
}
|
99
118
|
}
|
data/kitchen-ec2.gemspec
CHANGED
@@ -18,10 +18,9 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency "test-kitchen", "~> 1.4"
|
21
|
+
gem.add_dependency "test-kitchen", "~> 1.4", ">= 1.4.1"
|
22
22
|
gem.add_dependency "excon"
|
23
23
|
gem.add_dependency "multi_json"
|
24
|
-
gem.add_dependency "aws-sdk-v1", "~> 1.59.0"
|
25
24
|
gem.add_dependency "aws-sdk", "~> 2"
|
26
25
|
|
27
26
|
gem.add_development_dependency "rspec", "~> 3.2"
|
@@ -34,6 +33,5 @@ Gem::Specification.new do |gem|
|
|
34
33
|
# may introduce new and undesireable style choices which would be immediately
|
35
34
|
# enforced in CI
|
36
35
|
gem.add_development_dependency "finstyle", "1.4.0"
|
37
|
-
gem.add_development_dependency "cane", "2.6.2"
|
38
36
|
gem.add_development_dependency "climate_control"
|
39
37
|
end
|
data/lib/kitchen/driver/ec2.rb
CHANGED
@@ -46,7 +46,11 @@ module Kitchen
|
|
46
46
|
default_config :ebs_optimized, false
|
47
47
|
default_config :security_group_ids, nil
|
48
48
|
default_config :tags, "created-by" => "test-kitchen"
|
49
|
-
default_config :user_data
|
49
|
+
default_config :user_data do |driver|
|
50
|
+
if driver.windows_os?
|
51
|
+
driver.default_windows_user_data
|
52
|
+
end
|
53
|
+
end
|
50
54
|
default_config :private_ip_address, nil
|
51
55
|
default_config :iam_profile_name, nil
|
52
56
|
default_config :price, nil
|
@@ -200,6 +204,14 @@ module Kitchen
|
|
200
204
|
info("EC2 instance <#{state[:server_id]}> created.")
|
201
205
|
wait_until_ready(server, state)
|
202
206
|
|
207
|
+
if windows_os? &&
|
208
|
+
instance.transport[:username] =~ /administrator/i &&
|
209
|
+
instance.transport[:password].nil?
|
210
|
+
# If we're logging into the administrator user and a password isn't
|
211
|
+
# supplied, try to fetch it from the AWS instance
|
212
|
+
fetch_windows_admin_password(server, state)
|
213
|
+
end
|
214
|
+
|
203
215
|
info("EC2 instance <#{state[:server_id]}> ready.")
|
204
216
|
instance.transport.connection(state).wait_until_ready
|
205
217
|
create_ec2_json(state)
|
@@ -322,11 +334,35 @@ module Kitchen
|
|
322
334
|
# we still have it, even if it will change later
|
323
335
|
state[:hostname] = hostname
|
324
336
|
# Euca instances often report ready before they have an IP
|
325
|
-
aws_instance.exists? &&
|
337
|
+
ready = aws_instance.exists? &&
|
326
338
|
aws_instance.state.name == "running" &&
|
327
339
|
hostname != "0.0.0.0"
|
340
|
+
if ready && windows_os?
|
341
|
+
output = server.console_output.output
|
342
|
+
unless output.nil?
|
343
|
+
output = Base64.decode64(output)
|
344
|
+
debug "Console output: --- \n#{output}"
|
345
|
+
end
|
346
|
+
ready = !!(output =~ /Windows is Ready to use/)
|
347
|
+
end
|
348
|
+
ready
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
# rubocop:disable Lint/UnusedBlockArgument
|
353
|
+
def fetch_windows_admin_password(server, state)
|
354
|
+
wait_with_destroy(server, state, "to fetch windows admin password") do |aws_instance|
|
355
|
+
enc = server.client.get_password_data(
|
356
|
+
:instance_id => state[:server_id]
|
357
|
+
).password_data
|
358
|
+
# Password data is blank until password is available
|
359
|
+
!enc.nil? && !enc.empty?
|
328
360
|
end
|
361
|
+
pass = server.decrypt_windows_password(instance.transport[:ssh_key])
|
362
|
+
state[:password] = pass
|
363
|
+
info("Retrieved Windows password for instance <#{state[:server_id]}>.")
|
329
364
|
end
|
365
|
+
# rubocop:enable Lint/UnusedBlockArgument
|
330
366
|
|
331
367
|
def wait_with_destroy(server, state, status_msg, &block)
|
332
368
|
wait_log = proc do |attempts|
|
@@ -391,10 +427,56 @@ module Kitchen
|
|
391
427
|
end
|
392
428
|
|
393
429
|
def create_ec2_json(state)
|
394
|
-
|
395
|
-
"
|
396
|
-
|
430
|
+
if windows_os?
|
431
|
+
cmd = "mkdir \\etc\\chef\\ohai\\hints; echo $null >> \\etc\\chef\\ohai\\hints\\ec2.json"
|
432
|
+
else
|
433
|
+
cmd = "sudo mkdir -p /etc/chef/ohai/hints;sudo touch /etc/chef/ohai/hints/ec2.json"
|
434
|
+
end
|
435
|
+
instance.transport.connection(state).execute(cmd)
|
436
|
+
end
|
437
|
+
|
438
|
+
# rubocop:disable Metrics/MethodLength, Metrics/LineLength
|
439
|
+
def default_windows_user_data
|
440
|
+
# Preparing custom static admin user if we defined something other than Administrator
|
441
|
+
custom_admin_script = ""
|
442
|
+
if !(instance.transport[:username] =~ /administrator/i) && instance.transport[:password]
|
443
|
+
custom_admin_script = Kitchen::Util.outdent!(<<-EOH)
|
444
|
+
"Disabling Complex Passwords" >> $logfile
|
445
|
+
$seccfg = [IO.Path]::GetTempFileName()
|
446
|
+
& secedit.exe /export /cfg $seccfg >> $logfile
|
447
|
+
(Get-Content $seccfg) | Foreach-Object {$_ -replace "PasswordComplexity\\s*=\\s*1", "PasswordComplexity = 0"} | Set-Content $seccfg
|
448
|
+
& secedit.exe /configure /db $env:windir\\security\\new.sdb /cfg $seccfg /areas SECURITYPOLICY >> $logfile
|
449
|
+
& cp $seccfg "c:\\"
|
450
|
+
& del $seccfg
|
451
|
+
$username="#{instance.transport[:username]}"
|
452
|
+
$password="#{instance.transport[:password]}"
|
453
|
+
"Creating static user: $username" >> $logfile
|
454
|
+
& net.exe user /y /add $username $password >> $logfile
|
455
|
+
"Adding $username to Administrators" >> $logfile
|
456
|
+
& net.exe localgroup Administrators /add $username >> $logfile
|
457
|
+
EOH
|
458
|
+
end
|
459
|
+
|
460
|
+
# Returning the fully constructed PowerShell script to user_data
|
461
|
+
Kitchen::Util.outdent!(<<-EOH)
|
462
|
+
<powershell>
|
463
|
+
$logfile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Logs\\kitchen-ec2.log"
|
464
|
+
#PS Remoting and & winrm.cmd basic config
|
465
|
+
Enable-PSRemoting -Force -SkipNetworkProfileCheck
|
466
|
+
& winrm.cmd set winrm/config '@{MaxTimeoutms="1800000"}' >> $logfile
|
467
|
+
& winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile
|
468
|
+
& winrm.cmd set winrm/config/winrs '@{MaxShellsPerUser="50"}' >> $logfile
|
469
|
+
#Server settings - support username/password login
|
470
|
+
& winrm.cmd set winrm/config/service/auth '@{Basic="true"}' >> $logfile
|
471
|
+
& winrm.cmd set winrm/config/service '@{AllowUnencrypted="true"}' >> $logfile
|
472
|
+
& winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile
|
473
|
+
#Firewall Config
|
474
|
+
& netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any >> $logfile
|
475
|
+
#{custom_admin_script}
|
476
|
+
</powershell>
|
477
|
+
EOH
|
397
478
|
end
|
479
|
+
# rubocop:enable Metrics/MethodLength, Metrics/LineLength
|
398
480
|
|
399
481
|
end
|
400
482
|
end
|
@@ -27,11 +27,7 @@ describe Kitchen::Driver::Ec2 do
|
|
27
27
|
let(:logger) { Logger.new(logged_output) }
|
28
28
|
let(:config) { { :aws_ssh_key_id => "key", :image_id => "ami-1234567" } }
|
29
29
|
let(:platform) { Kitchen::Platform.new(:name => "fooos-99") }
|
30
|
-
let(:suite) { Kitchen::Suite.new(:name => "suitey") }
|
31
|
-
let(:verifier) { Kitchen::Verifier::Dummy.new }
|
32
|
-
let(:provisioner) { Kitchen::Provisioner::Dummy.new }
|
33
30
|
let(:transport) { Kitchen::Transport::Dummy.new }
|
34
|
-
let(:state_file) { double("state_file") }
|
35
31
|
let(:generator) { instance_double(Kitchen::Driver::Aws::InstanceGenerator) }
|
36
32
|
# There is too much name overlap I let creep in - my `client` is actually
|
37
33
|
# a wrapper around the actual ec2 client
|
@@ -43,21 +39,20 @@ describe Kitchen::Driver::Ec2 do
|
|
43
39
|
let(:driver) { Kitchen::Driver::Ec2.new(config) }
|
44
40
|
|
45
41
|
let(:instance) do
|
46
|
-
|
47
|
-
|
48
|
-
:driver => driver,
|
42
|
+
instance_double(
|
43
|
+
Kitchen::Instance,
|
49
44
|
:logger => logger,
|
50
|
-
:suite => suite,
|
51
|
-
:platform => platform,
|
52
|
-
:provisioner => provisioner,
|
53
45
|
:transport => transport,
|
54
|
-
:
|
46
|
+
:platform => platform,
|
47
|
+
:to_str => "str"
|
55
48
|
)
|
56
49
|
end
|
57
50
|
|
58
51
|
before do
|
59
52
|
allow(Kitchen::Driver::Aws::InstanceGenerator).to receive(:new).and_return(generator)
|
60
53
|
allow(Kitchen::Driver::Aws::Client).to receive(:new).and_return(client)
|
54
|
+
allow(driver).to receive(:windows_os?).and_return(false)
|
55
|
+
allow(driver).to receive(:instance).and_return(instance)
|
61
56
|
end
|
62
57
|
|
63
58
|
it "driver api_version is 2" do
|
@@ -267,6 +262,34 @@ describe Kitchen::Driver::Ec2 do
|
|
267
262
|
end
|
268
263
|
end
|
269
264
|
|
265
|
+
describe "#fetch_windows_admin_password" do
|
266
|
+
let(:msg) { "to fetch windows admin password" }
|
267
|
+
let(:aws_instance) { double("aws instance") }
|
268
|
+
let(:server_id) { "server_id" }
|
269
|
+
let(:encrypted_password) { "alksdofw" }
|
270
|
+
let(:data) { double("data", :password_data => encrypted_password) }
|
271
|
+
let(:password) { "password" }
|
272
|
+
let(:transport) { { :ssh_key => "foo" } }
|
273
|
+
|
274
|
+
before do
|
275
|
+
state[:server_id] = server_id
|
276
|
+
expect(driver).to receive(:wait_with_destroy).with(server, state, msg).and_yield(aws_instance)
|
277
|
+
end
|
278
|
+
|
279
|
+
after do
|
280
|
+
expect(state[:password]).to eq(password)
|
281
|
+
end
|
282
|
+
|
283
|
+
it "fetches and decrypts the windows password" do
|
284
|
+
expect(server).to receive_message_chain("client.get_password_data").with(
|
285
|
+
:instance_id => server_id
|
286
|
+
).and_return(data)
|
287
|
+
expect(server).to receive(:decrypt_windows_password).with("foo").and_return(password)
|
288
|
+
driver.fetch_windows_admin_password(server, state)
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
|
270
293
|
describe "#wait_with_destroy" do
|
271
294
|
let(:tries) { 111 }
|
272
295
|
let(:sleep) { 222 }
|
@@ -299,6 +322,65 @@ describe Kitchen::Driver::Ec2 do
|
|
299
322
|
end
|
300
323
|
end
|
301
324
|
|
325
|
+
describe "#create" do
|
326
|
+
let(:server) { double("aws server object", :id => id) }
|
327
|
+
let(:id) { "i-12345" }
|
328
|
+
|
329
|
+
before do
|
330
|
+
expect(driver).to receive(:copy_deprecated_configs).with(state)
|
331
|
+
end
|
332
|
+
|
333
|
+
it "returns if the instance is already created" do
|
334
|
+
state[:server_id] = id
|
335
|
+
expect(driver.create(state)).to eq(nil)
|
336
|
+
end
|
337
|
+
|
338
|
+
shared_examples "common create" do
|
339
|
+
it "successfully creates and tags the instance" do
|
340
|
+
expect(actual_client).to receive(:wait_until).with(
|
341
|
+
:instance_exists,
|
342
|
+
:instance_ids => [server.id]
|
343
|
+
)
|
344
|
+
expect(driver).to receive(:tag_server).with(server)
|
345
|
+
expect(driver).to receive(:wait_until_ready).with(server, state)
|
346
|
+
expect(transport).to receive_message_chain("connection.wait_until_ready")
|
347
|
+
expect(driver).to receive(:create_ec2_json).with(state)
|
348
|
+
driver.create(state)
|
349
|
+
expect(state[:server_id]).to eq(id)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
context "non-windows on-depand instance" do
|
354
|
+
before do
|
355
|
+
expect(driver).to receive(:submit_server).and_return(server)
|
356
|
+
end
|
357
|
+
|
358
|
+
include_examples "common create"
|
359
|
+
end
|
360
|
+
|
361
|
+
context "config is for a spot instance" do
|
362
|
+
before do
|
363
|
+
config[:price] = 1
|
364
|
+
expect(driver).to receive(:submit_spot).with(state).and_return(server)
|
365
|
+
end
|
366
|
+
|
367
|
+
include_examples "common create"
|
368
|
+
end
|
369
|
+
|
370
|
+
context "instance is a windows machine" do
|
371
|
+
before do
|
372
|
+
expect(driver).to receive(:windows_os?).and_return(true)
|
373
|
+
expect(transport).to receive(:[]).with(:username).and_return("administrator")
|
374
|
+
expect(transport).to receive(:[]).with(:password).and_return(nil)
|
375
|
+
expect(driver).to receive(:submit_server).and_return(server)
|
376
|
+
expect(driver).to receive(:fetch_windows_admin_password).with(server, state)
|
377
|
+
end
|
378
|
+
|
379
|
+
include_examples "common create"
|
380
|
+
end
|
381
|
+
|
382
|
+
end
|
383
|
+
|
302
384
|
describe "#destroy" do
|
303
385
|
context "when state[:server_id] is nil" do
|
304
386
|
it "returns nil" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0.rc.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Nichol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.4.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.4.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: excon
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +58,6 @@ dependencies:
|
|
52
58
|
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: aws-sdk-v1
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.59.0
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.59.0
|
69
61
|
- !ruby/object:Gem::Dependency
|
70
62
|
name: aws-sdk
|
71
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,20 +156,6 @@ dependencies:
|
|
164
156
|
- - '='
|
165
157
|
- !ruby/object:Gem::Version
|
166
158
|
version: 1.4.0
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: cane
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - '='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 2.6.2
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - '='
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 2.6.2
|
181
159
|
- !ruby/object:Gem::Dependency
|
182
160
|
name: climate_control
|
183
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,7 +177,6 @@ executables: []
|
|
199
177
|
extensions: []
|
200
178
|
extra_rdoc_files: []
|
201
179
|
files:
|
202
|
-
- ".cane"
|
203
180
|
- ".gitignore"
|
204
181
|
- ".rspec"
|
205
182
|
- ".rubocop.yml"
|
@@ -235,9 +212,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
212
|
version: '0'
|
236
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
214
|
requirements:
|
238
|
-
- - "
|
215
|
+
- - ">"
|
239
216
|
- !ruby/object:Gem::Version
|
240
|
-
version:
|
217
|
+
version: 1.3.1
|
241
218
|
requirements: []
|
242
219
|
rubyforge_project:
|
243
220
|
rubygems_version: 2.4.7
|
data/.cane
DELETED