knife-ec2 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 889db53ef2c074e00e6f39d699546e1c559aa8aa
4
- data.tar.gz: 9295959d153ee997e857113dde66c746435502a3
3
+ metadata.gz: 0453d28ca1ee7ca9304f301fb2cf3e441cb10831
4
+ data.tar.gz: bee091b5395aa6fc75fed85f9810b29ba7547b5e
5
5
  SHA512:
6
- metadata.gz: f7921659633817867c17ddfcde5f256128761e8b5c9c1a675786099a4244d5d134aed0df8b8c2f6bb915df8fe1de24ef1ced5fdfab98981ad27635a8b4b1935a
7
- data.tar.gz: 713004b60d245461dc9bede11abac218cc29b77fc898207abc2388d0d5bf45b1fb4fd59575328e00a38d3f56d22252f6f3cc812389a54289f12a905ea27bbcb3
6
+ metadata.gz: 01ccbc1d97798ae53cf5c6155d3398dc7c5ab0727e99effc608ff624f8b72cfca9b36ffd4e19c48e6d5c5baff263cde0060d490f410d437bace8e145aaf44258
7
+ data.tar.gz: 88b79da6a34a5cc3292b202951b327b4bbb6f1124da79ef705a4efe20d64dcddffdc235ccc8cb117ca2fd7dde929bbd7c8186d7608f9d656e56a94dee8a2773a
@@ -0,0 +1,21 @@
1
+ # Version:
2
+
3
+ [Version of the project installed]
4
+
5
+ # Environment: [Details about the environment such as the Operating System, cookbook details, etc...]
6
+
7
+ # Scenario:
8
+
9
+ [What you are trying to achieve and you can't?]
10
+
11
+ # Steps to Reproduce:
12
+
13
+ [If you are filing an issue what are the things we need to do in order to repro your problem?]
14
+
15
+ # Expected Result:
16
+
17
+ [What are you expecting to happen as the consequence of above reproduction steps?]
18
+
19
+ # Actual Result:
20
+
21
+ [What actually happens after the reproduction steps?]
@@ -1,14 +1,27 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ dist: trusty
3
4
  sudo: false
4
5
 
5
6
  # Early warning system to catch if Rubygems breaks something
6
7
  before_install:
7
8
  - gem update --system
9
+ - gem uninstall bundler -a -x
8
10
  - gem install bundler
9
11
  - rm -f .bundle/config
10
12
 
11
13
  rvm:
12
- - 2.2.5
13
- - 2.3.1
14
+ - 2.2.7
15
+ - 2.3.4
16
+ - 2.4.1
17
+ - ruby-head
18
+
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: ruby-head
22
+
14
23
  script: bundle exec rake spec
24
+
25
+ branches:
26
+ only:
27
+ - master
@@ -5,6 +5,15 @@ Note: this log contains only changes from knife-ec2 release 0.8.0 and later
5
5
  prior to release 0.8.0, please visit the [source repository](https://github.com/chef/knife-ec2/commits).
6
6
 
7
7
 
8
+ ## Latest Release 0.16.0 (2017-11-07)
9
+ * [knife-ec2:#503](https://github.com/chef/knife-ec2/pull/503) Update list of instance_types that support ebs-encryption.
10
+ * [knife-ec2:#496](https://github.com/chef/knife-ec2/pull/496) Change Winrm cert to 10 year expiry.
11
+ * [knife-ec2:#492](https://github.com/chef/knife-ec2/pull/492) Added support to tag node details to chef.
12
+ * [knife-ec2:#490](https://github.com/chef/knife-ec2/pull/490) Improper alignment of EC2 flavor list.
13
+ * [knife-ec2:#489](https://github.com/chef/knife-ec2/pull/489) Added support to handle long passwords in windows.
14
+ * [knife-ec2:#488](https://github.com/chef/knife-ec2/pull/488) Added support to tag EBS volumes on node creation.
15
+ * [knife-ec2:#487](https://github.com/chef/knife-ec2/pull/487) Added new column description in EC2 AMIs list.
16
+
8
17
  ## Latest Release 0.15.0 (2017-02-15)
9
18
  * [knife-ec2:#484](https://github.com/chef/knife-ec2/pull/484) sleep for collecting windows password
10
19
  * [knife-ec2:#481](https://github.com/chef/knife-ec2/pull/481) Updated readme for EC2 AMI list
data/README.md CHANGED
@@ -208,6 +208,15 @@ View additional information on configuring Windows images for bootstrap in the d
208
208
  Users can also include the ec2 server id in the node name by placing `%s` in the string passed to the `--chef-node-name` option. The %s is replaced by the ec2 server id dynamically.
209
209
  e.g. `-N "www-server-%s" or --chef-node-name "www-server-%s"`
210
210
 
211
+ #### Tagging node in Chef
212
+
213
+ Users can use option `--tag-node-in-chef` for tagging node in EC2 and chef both with `knife ec2 server create` command. If user does not pass this option, then the node will be tagged only in EC2.
214
+
215
+ #### Tagging EBS Volumes
216
+
217
+ Users can attach ebs volumes to a new instance being created with knife-ec2 using `--volume-tags Tag=Value[,Tag=Value...]`.
218
+
219
+
211
220
  #### Bootstrap Windows (2012 R2 and above platform) instance without user-data through winrm ssl transport
212
221
 
213
222
  Users can bootstrap the Windows instance without the need to provide the user-data. `knife-ec2` has the ability to bootstrap the Windows instance through `winrm protocol` using the `ssl` transport. This requires users to set `--winrm-transport` option as `ssl` and `--winrm-ssl-verify-mode` option as `verify_none`. This will do the necessary winrm ssl transport configurations on the target node and the bootstrap will just work.
@@ -260,10 +269,21 @@ knife ec2 ami list
260
269
  ```
261
270
  :Allowed platform windows, ubuntu, debian, centos, fedora, rhel, nginx, turnkey, jumpbox, coreos, cisco, amazon, nessus
262
271
  ```
272
+ - **Search:**
273
+ User can search any string into the description column by using -s or --search:
274
+
275
+ **command:** knife ec2 ami list -s (search_keyword)
276
+
277
+ ```
278
+ :search_keyword Any String or number
279
+ ```
263
280
 
264
281
  ### `knife ec2 server list`
265
282
  Outputs a list of all servers in the currently configured AWS account. **Note, this shows all instances associated with the account, some of which may not be currently managed by the Chef server.**
266
283
 
284
+ ### `knife ec2 flavor list`
285
+ Outputs a list of all instance types comprising varying combinations of CPU, memory, storage, and architecture capacity of the currently configured AWS account. **Note, this shows all instances type associated with the account.**
286
+
267
287
  ### `knife ec2 server delete`
268
288
  Deletes an existing server in the currently configured AWS account. **By default, this does not delete the associated node and client objects from the Chef server. To do so, add the `--purge` flag**
269
289
 
@@ -7,26 +7,30 @@ Example Note:
7
7
  Details about the thing that changed that needs to get included in the Release Notes in markdown.
8
8
  -->
9
9
 
10
- # knife-ec2 0.15.0 release notes:
11
- In this release we have added a command to list EC2 AMIs. Also added a feature to append server_id to the chef-node-name. There are a couple of bug fixes as well.
10
+ # knife-ec2 0.16.0 release notes:
11
+ In this release we have added features for tagging EBS volumes and tagging node in Chef. There are a couple of bug fixes and enhancement as well.
12
12
 
13
- ## Features added in knife-ec2 0.15.0
13
+ ## Features added in knife-ec2 0.16.0
14
14
 
15
- * Added command to list EC2 AMIs using `knife ec2 ami list` PR: [482](https://github.com/chef/knife-ec2/pull/482)
15
+ * Added support to tag node details to chef while node creation using `--tag-node-in-chef` PR: [492](https://github.com/chef/knife-ec2/pull/492).
16
16
 
17
- * Added support to insert ec2 server id into node name using -N "<Node Name>%s" PR: [471](https://github.com/chef/knife-ec2/pull/471)
17
+ * Added support to tag EBS volumes while node creation using `--volume-tags Tag=Value[,Tag=Value...]` PR: [488](https://github.com/chef/knife-ec2/pull/488).
18
18
 
19
- * Changed source of vm name to allow for hosts without public ip addresses PR: [478](https://github.com/chef/knife-ec2/pull/478)
20
19
 
21
- * Automatically pass tags to Chef as well as EC2 PR: [476](https://github.com/chef/knife-ec2/pull/476)
20
+ ## Enhancement in knife-ec2 0.16.0
22
21
 
22
+ * Update list of instance types that support ebs-encryption PR: [503](https://github.com/chef/knife-ec2/pull/503)
23
23
 
24
- ## Fixed issue in knife-ec2 0.15.0
24
+ * Enhanced Winrm cert to 10 year expiry PR: [496](https://github.com/chef/knife-ec2/pull/496).
25
25
 
26
- * Wait for Windows Admin password to be available PR: [484](https://github.com/chef/knife-ec2/pull/484), issue: [479](https://github.com/chef/knife-ec2/issues/479), issue: [453](https://github.com/chef/knife-ec2/issues/453)
26
+ * Improper alignment of EC2 flavor list command `knife ec2 flavor list` PR: [490](https://github.com/chef/knife-ec2/pull/490)
27
27
 
28
- * Fix where `--yes` option was not being passed to bootstrap PR: [458](https://github.com/chef/knife-ec2/pull/458)
28
+ * Added new column description in EC2 AMIs list command `knife ec2 ami list` PR: [487](https://github.com/chef/knife-ec2/pull/487)
29
29
 
30
- * In VPC mode use private IP when public IP and DNS are not available PR: [468](https://github.com/chef/knife-ec2/pull/468), issue: [344](https://github.com/chef/knife-ec2/issues/344)
30
+ ## Fixed issue in knife-ec2 0.16.0
31
31
 
32
- * Default value and description improved for `--ebs-volume-type` improved for clarity PR: [464](https://github.com/chef/knife-ec2/pull/464), issue: [450](https://github.com/chef/knife-ec2/issues/450), issue [451](https://github.com/chef/knife-ec2/issues/451)
32
+ * Update bundler to resolve travis failure PR: [502](https://github.com/chef/knife-ec2/pull/502)
33
+
34
+ * Fix issue Tag node in Chef PR: [492](https://github.com/chef/knife-ec2/pull/492) issue: [234](https://github.com/chef/knife-ec2/issues/234).
35
+
36
+ * Added support to handle long passwords in windows PR: [489](https://github.com/chef/knife-ec2/pull/489) issue: [470](https://github.com/chef/knife-ec2/issues/470)
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'mime-types'
22
22
  s.add_dependency 'knife-windows', '~> 1.0'
23
23
 
24
- s.add_development_dependency 'chef', '~> 12.0', '>= 12.2.1'
24
+ s.add_development_dependency 'chef', '>= 12.2.1'
25
25
  s.add_development_dependency 'rspec', '~> 3.0'
26
- s.add_development_dependency 'rake', '~> 11.0'
26
+ s.add_development_dependency 'rake'
27
27
  s.add_development_dependency 'sdoc', '~> 0.3'
28
28
 
29
29
  s.require_paths = ['lib']
@@ -46,13 +46,18 @@ class Chef
46
46
  option :platform,
47
47
  :short => "-p PLATFORM",
48
48
  :long => "--platform PLATFORM",
49
- :description => "Platform of the server. Allowed values are ubuntu, debian, centos, fedora, rhel, nginx, turnkey, jumpbox, coreos, cisco, amazon, nessus"
49
+ :description => "Platform of the server. Allowed values are windows, ubuntu, debian, centos, fedora, rhel, nginx, turnkey, jumpbox, coreos, cisco, amazon, nessus"
50
50
 
51
- option :owner,
51
+ option :owner,
52
52
  :short => "-o OWNER",
53
53
  :long => "--owner OWNER",
54
54
  :description => "The server owner (self, aws-marketplace, microsoft). Default is aws-marketplace"
55
55
 
56
+ option :search,
57
+ :short => "-s SEARCH",
58
+ :long => "--search SEARCH",
59
+ :description => "Filter AMIs list as per search keywords."
60
+
56
61
  def run
57
62
  $stdout.sync = true
58
63
 
@@ -64,7 +69,8 @@ class Chef
64
69
  ui.color("Platform", :bold),
65
70
  ui.color("Architecture", :bold),
66
71
  ui.color("Size", :bold),
67
- ui.color("Name", :bold)
72
+ ui.color("Name", :bold),
73
+ ui.color("Description", :bold)
68
74
  ].flatten.compact
69
75
 
70
76
  output_column_count = server_list.length
@@ -74,28 +80,42 @@ class Chef
74
80
  rescue Exception => api_error
75
81
  raise api_error
76
82
  end
83
+
77
84
  servers.body["imagesSet"].each do |server|
78
- server_name = server["name"]
79
- server["platform"] = find_server_platform(server_name) unless server["platform"]
85
+ server["platform"] = find_server_platform(server["name"]) unless server["platform"]
80
86
 
81
- if locate_config_value(:platform)
87
+ if (locate_config_value(:platform) && locate_config_value(:search))
88
+ locate_config_value(:search).downcase!
89
+ if (server["description"] && server["platform"] == locate_config_value(:platform) && server["description"].downcase.include?(locate_config_value(:search)))
90
+ server_list += get_server_list(server)
91
+ end
92
+ elsif locate_config_value(:platform)
82
93
  if server["platform"] == locate_config_value(:platform)
83
- server_list << server["imageId"]
84
- server_list << server["platform"]
85
- server_list << server["architecture"]
86
- server_list << server["blockDeviceMapping"].first["volumeSize"].to_s
87
- server_list << server_name.split(/\W+/).first
94
+ server_list += get_server_list(server)
95
+ end
96
+ elsif locate_config_value(:search)
97
+ locate_config_value(:search).downcase!
98
+ if (server["description"] && server["description"].downcase.include?(locate_config_value(:search)))
99
+ server_list += get_server_list(server)
88
100
  end
89
101
  else
90
- server_list << server["imageId"]
91
- server_list << server["platform"]
92
- server_list << server["architecture"]
93
- server_list << server["blockDeviceMapping"].first["volumeSize"].to_s
94
- server_list << server_name.split(/\W+/).first
102
+ server_list += get_server_list(server)
95
103
  end
96
104
  end
97
105
  puts ui.list(server_list, :uneven_columns_across, output_column_count)
98
106
  end
107
+
108
+ private
109
+
110
+ def get_server_list(server)
111
+ server_list = []
112
+ server_list << server["imageId"]
113
+ server_list << server["platform"]
114
+ server_list << server["architecture"]
115
+ server_list << server["blockDeviceMapping"].first["volumeSize"].to_s
116
+ server_list << server["name"].split(/\W+/).first
117
+ server_list << server["description"]
118
+ end
99
119
  end
100
120
  end
101
121
  end
@@ -222,13 +222,12 @@ class Chef
222
222
 
223
223
  # All valid platforms
224
224
  def valid_platforms
225
- ["ubuntu", "debian", "centos", "fedora", "rhel", "nginx", "turnkey", "jumpbox", "coreos", "cisco", "amazon", "nessus"]
225
+ ["windows", "ubuntu", "debian", "centos", "fedora", "rhel", "nginx", "turnkey", "jumpbox", "coreos", "cisco", "amazon", "nessus"]
226
226
  end
227
227
 
228
228
  # Get the platform from server name
229
229
  def find_server_platform(server_name)
230
- available_platforms = valid_platforms
231
- get_platform = available_platforms.select { |name| server_name.downcase.include?(name) }
230
+ get_platform = valid_platforms.select { |name| server_name.downcase.include?(name) }
232
231
  return get_platform.first
233
232
  end
234
233
 
@@ -29,6 +29,7 @@ class Chef
29
29
  def run
30
30
 
31
31
  validate!
32
+ custom_warnings!
32
33
 
33
34
  flavor_list = [
34
35
  ui.color('ID', :bold),
@@ -37,8 +38,16 @@ class Chef
37
38
  ui.color('RAM', :bold),
38
39
  ui.color('Disk', :bold),
39
40
  ui.color('Cores', :bold)
40
- ]
41
- flavors = connection.flavors.sort_by(&:id)
41
+ ].flatten.compact
42
+
43
+ output_column_count = flavor_list.length
44
+
45
+ begin
46
+ flavors = connection.flavors.sort_by(&:id)
47
+ rescue Exception => api_error
48
+ raise api_error
49
+ end
50
+
42
51
  if (config[:format] == 'summary')
43
52
  flavors.each do |flavor|
44
53
  flavor_list << flavor.id.to_s
@@ -48,10 +57,10 @@ class Chef
48
57
  flavor_list << "#{flavor.disk.to_s} GB"
49
58
  flavor_list << flavor.cores.to_s
50
59
  end
51
- puts ui.list(flavor_list, :columns_across, 6)
52
- else
60
+ puts ui.list(flavor_list, :uneven_columns_across, output_column_count)
61
+ else
53
62
  output(format_for_display(flavors))
54
- end
63
+ end
55
64
  end
56
65
  end
57
66
  end
@@ -442,6 +442,17 @@ class Chef
442
442
  :boolean => true,
443
443
  :default => false
444
444
 
445
+ option :volume_tags,
446
+ :long => "--volume-tags Tag=Value[,Tag=Value...]",
447
+ :description => "Tag the Root volume",
448
+ :proc => Proc.new { |volume_tags| volume_tags.split(',') }
449
+
450
+ option :tag_node_in_chef,
451
+ :long => "--tag-node-in-chef",
452
+ :description => "Flag for tagging node in ec2 and chef both",
453
+ :boolean => true,
454
+ :default => false
455
+
445
456
  def run
446
457
  $stdout.sync = true
447
458
  validate!
@@ -489,6 +500,7 @@ class Chef
489
500
  begin
490
501
  @server = connection.servers.create(create_server_def)
491
502
  rescue => error
503
+ error.message.sub("download completed, but downloaded file not found", "Verify that you have public internet access.")
492
504
  ui.error error.message
493
505
  Chef::Log.debug("#{error.backtrace.join("\n")}")
494
506
  exit
@@ -509,6 +521,11 @@ class Chef
509
521
 
510
522
  printed_tags = hashed_tags.map{ |tag, val| "#{tag}: #{val}" }.join(", ")
511
523
 
524
+ hashed_volume_tags={}
525
+ volume_tags = locate_config_value(:volume_tags)
526
+ volume_tags.map{ |t| key,val=t.split('='); hashed_volume_tags[key]=val} unless volume_tags.nil?
527
+ printed_volume_tags = hashed_volume_tags.map{ |tag, val| "#{tag}: #{val}" }.join(", ")
528
+
512
529
  msg_pair("Instance ID", @server.id)
513
530
  msg_pair("Flavor", @server.flavor_id)
514
531
  msg_pair("Image", @server.image_id)
@@ -530,6 +547,7 @@ class Chef
530
547
  msg_pair("IAM Profile", locate_config_value(:iam_instance_profile))
531
548
 
532
549
  msg_pair("Tags", printed_tags)
550
+ msg_pair("Volume Tags", printed_volume_tags)
533
551
  msg_pair("SSH Key", @server.key_name)
534
552
 
535
553
  print "\n#{ui.color("Waiting for EC2 to create the instance", :magenta)}"
@@ -543,6 +561,7 @@ class Chef
543
561
  tries = 6
544
562
  begin
545
563
  create_tags(hashed_tags) unless hashed_tags.empty?
564
+ create_volume_tags(hashed_volume_tags) unless hashed_volume_tags.empty?
546
565
  associate_eip(elastic_ip) if config[:associate_eip]
547
566
  enable_classic_link(config[:classic_link_vpc_id], config[:classic_link_vpc_security_group_ids]) if config[:classic_link_vpc_id]
548
567
  rescue Fog::Compute::AWS::NotFound, Fog::Errors::Error
@@ -616,6 +635,7 @@ class Chef
616
635
  msg_pair("Tags", printed_tags)
617
636
  msg_pair("SSH Key", @server.key_name)
618
637
  msg_pair("Root Device Type", @server.root_device_type)
638
+ msg_pair("Root Volume Tags", printed_volume_tags)
619
639
  if @server.root_device_type == "ebs"
620
640
  device_map = @server.block_device_mapping.first
621
641
  msg_pair("Root Volume ID", device_map['volumeId'])
@@ -785,7 +805,8 @@ class Chef
785
805
  bootstrap.config[:msi_url] = locate_config_value(:msi_url)
786
806
  bootstrap.config[:install_as_service] = locate_config_value(:install_as_service)
787
807
  bootstrap.config[:session_timeout] = locate_config_value(:session_timeout)
788
- bootstrap.config[:tags] = config[:tags]
808
+ bootstrap.config[:tags] = config[:tags] if locate_config_value(:tag_node_in_chef)
809
+
789
810
  if locate_config_value(:chef_node_name)
790
811
  bootstrap.config[:chef_node_name] = evaluate_node_name(locate_config_value(:chef_node_name))
791
812
  else
@@ -802,7 +823,8 @@ class Chef
802
823
  bootstrap.config[:ssh_port] = config[:ssh_port]
803
824
  bootstrap.config[:ssh_gateway] = config[:ssh_gateway]
804
825
  bootstrap.config[:identity_file] = config[:identity_file]
805
- bootstrap.config[:tags] = config[:tags]
826
+ bootstrap.config[:tags] = config[:tags] if locate_config_value(:tag_node_in_chef)
827
+
806
828
  if locate_config_value(:chef_node_name)
807
829
  bootstrap.config[:chef_node_name] = evaluate_node_name(locate_config_value(:chef_node_name))
808
830
  else
@@ -914,11 +936,14 @@ class Chef
914
936
  ui.error("--ebs-encrypted option requires valid flavor to be specified.")
915
937
  exit 1
916
938
  elsif (locate_config_value(:ebs_encrypted) and ! %w(m3.medium m3.large m3.xlarge m3.2xlarge m4.large m4.xlarge
917
- m4.2xlarge m4.4xlarge m4.10xlarge t2.micro t2.small t2.medium t2.large
918
- d2.xlarge d2.2xlarge d2.4xlarge d2.8xlarge c4.large c4.xlarge
919
- c4.2xlarge c4.4xlarge c4.8xlarge c3.large c3.xlarge c3.2xlarge
920
- c3.4xlarge c3.8xlarge cr1.8xlarge r3.large r3.xlarge r3.2xlarge
921
- r3.4xlarge r3.8xlarge i2.xlarge i2.2xlarge i2.4xlarge i2.8xlarge g2.2xlarge g2.8xlarge).include?(locate_config_value(:flavor)))
939
+ m4.2xlarge m4.4xlarge m4.10xlarge m4.16xlarge t2.nano t2.micro t2.small
940
+ t2.medium t2.large t2.xlarge t2.2xlarge d2.xlarge d2.2xlarge d2.4xlarge
941
+ d2.8xlarge c4.large c4.xlarge c4.2xlarge c4.4xlarge c4.8xlarge c3.large
942
+ c3.xlarge c3.2xlarge c3.4xlarge c3.8xlarge cr1.8xlarge r3.large r3.xlarge
943
+ r3.2xlarge r3.4xlarge r3.8xlarge r4.large r4.xlarge r4.2xlarge r4.4xlarge
944
+ r4.8xlarge r4.16xlarge x1.16xlarge x1.32xlarge i2.xlarge i2.2xlarge i2.4xlarge
945
+ i2.8xlarge i3.large i3.xlarge i3.2xlarge i3.4xlarge i3.8xlarge i3.16xlarge
946
+ f1.2xlarge f1.16xlarge g2.2xlarge g2.8xlarge p2.xlarge p2.8xlarge p2.16xlarge).include?(locate_config_value(:flavor)))
922
947
  ui.error("--ebs-encrypted option is not supported for #{locate_config_value(:flavor)} flavor.")
923
948
  exit 1
924
949
  end
@@ -950,6 +975,24 @@ class Chef
950
975
  exit 1
951
976
  end
952
977
 
978
+ volume_tags = locate_config_value(:volume_tags)
979
+ if !volume_tags.nil? and volume_tags.length != volume_tags.to_s.count('=')
980
+ ui.error("Volume Tags should be entered in a key = value pair")
981
+ exit 1
982
+ end
983
+
984
+ if (locate_config_value(:winrm_password).to_s.length > 14 )
985
+ ui.warn("The password provided is longer than 14 characters. Computers with Windows prior to Windows 2000 will not be able to use this account. Do you want to continue this operation? (Y/N):")
986
+ password_promt = STDIN.gets.chomp.upcase
987
+ if (password_promt == "N")
988
+ raise "Exiting as operation with password greater than 14 characters not accepted"
989
+ elsif (password_promt == "Y")
990
+ @allow_long_password = "/yes"
991
+ else
992
+ raise "The input provided is incorrect."
993
+ end
994
+ end
995
+
953
996
  end
954
997
 
955
998
  def tags
@@ -974,7 +1017,7 @@ class Chef
974
1017
  winrm_user = locate_config_value(:winrm_user).split("\\")
975
1018
  if (winrm_user[0] == ".") || (winrm_user[0] == "") ||(winrm_user.length == 1)
976
1019
  user_related_commands = <<-EOH
977
- net user /add #{locate_config_value(:winrm_user).delete('.\\')} #{windows_password};
1020
+ net user /add #{locate_config_value(:winrm_user).delete('.\\')} #{windows_password} #{@allow_long_password};
978
1021
  net localgroup Administrators /add #{locate_config_value(:winrm_user).delete('.\\')};
979
1022
  EOH
980
1023
  end
@@ -990,13 +1033,39 @@ $vm_name = invoke-restmethod -uri http://169.254.169.254/latest/meta-data/public
990
1033
  If (-Not $vm_name) {
991
1034
  $vm_name = invoke-restmethod -uri http://169.254.169.254/latest/meta-data/local-ipv4
992
1035
  }
993
- New-SelfSignedCertificate -certstorelocation cert:\\localmachine\\my -dnsname $vm_name
1036
+
1037
+ $name = new-object -com "X509Enrollment.CX500DistinguishedName.1"
1038
+ $name.Encode("CN=$vm_name", 0)
1039
+ $key = new-object -com "X509Enrollment.CX509PrivateKey.1"
1040
+ $key.ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
1041
+ $key.KeySpec = 1
1042
+ $key.Length = 2048
1043
+ $key.SecurityDescriptor = "D:PAI(A;;0xd01f01ff;;;SY)(A;;0xd01f01ff;;;BA)(A;;0x80120089;;;NS)"
1044
+ $key.MachineContext = 1
1045
+ $key.Create()
1046
+ $serverauthoid = new-object -com "X509Enrollment.CObjectId.1"
1047
+ $serverauthoid.InitializeFromValue("1.3.6.1.5.5.7.3.1")
1048
+ $ekuoids = new-object -com "X509Enrollment.CObjectIds.1"
1049
+ $ekuoids.add($serverauthoid)
1050
+ $ekuext = new-object -com "X509Enrollment.CX509ExtensionEnhancedKeyUsage.1"
1051
+ $ekuext.InitializeEncode($ekuoids)
1052
+ $cert = new-object -com "X509Enrollment.CX509CertificateRequestCertificate.1"
1053
+ $cert.InitializeFromPrivateKey(2, $key, "")
1054
+ $cert.Subject = $name
1055
+ $cert.Issuer = $cert.Subject
1056
+ $cert.NotBefore = get-date
1057
+ $cert.NotAfter = $cert.NotBefore.AddYears(10)
1058
+ $cert.X509Extensions.Add($ekuext)
1059
+ $cert.Encode()
1060
+ $enrollment = new-object -com "X509Enrollment.CX509Enrollment.1"
1061
+ $enrollment.InitializeFromRequest($cert)
1062
+ $certdata = $enrollment.CreateRequest(0)
1063
+ $enrollment.InstallResponse(2, $certdata, 0, "")
1064
+
994
1065
  $thumbprint = (Get-ChildItem -Path cert:\\localmachine\\my | Where-Object {$_.Subject -match "$vm_name"}).Thumbprint;
995
1066
  $create_listener_cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname=`"$vm_name`";CertificateThumbprint=`"$thumbprint`"}'"
996
1067
  iex $create_listener_cmd
997
-
998
1068
  netsh advfirewall firewall add rule name="WinRM HTTPS" protocol=TCP dir=in Localport=5986 remoteport=any action=allow localip=any remoteip=any profile=any enable=yes
999
-
1000
1069
  EOH
1001
1070
  end
1002
1071
 
@@ -1444,6 +1513,12 @@ EOH
1444
1513
  return node_name%server.id
1445
1514
  end
1446
1515
 
1516
+ def create_volume_tags(hashed_volume_tags)
1517
+ hashed_volume_tags.each_pair do |key,val|
1518
+ connection.tags.create :key => key, :value => val, :resource_id => @server.block_device_mapping.first['volumeId']
1519
+ end
1520
+ end
1521
+
1447
1522
  end
1448
1523
  end
1449
1524
  end