knife-ec2 0.11.0 → 0.12.0
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 +4 -4
- data/CHANGELOG.md +7 -1
- data/DOC_CHANGES.md +53 -60
- data/README.md +22 -0
- data/RELEASE_NOTES.md +29 -15
- data/knife-ec2.gemspec +28 -28
- data/lib/chef/knife/ec2_base.rb +30 -5
- data/lib/chef/knife/ec2_server_create.rb +13 -1
- data/lib/knife-ec2/version.rb +1 -1
- data/spec/unit/ec2_server_create_spec.rb +55 -7
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df82616670ab17b61699fa1d344500f0c80309fa
|
|
4
|
+
data.tar.gz: e4969b3ddaac2b8173b3bc74c6b94e1916058317
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d600ff181661d04c4702789a7042bbea70bd3c4998f4f4031e089d215c7d51e2a3499f375c1b7f3fb9a14f1186a5343b50b94fe53816b5448469c674bd252b0c
|
|
7
|
+
data.tar.gz: b46b7174e1833ff71798c762e2c95db0e4cf9c93fc6befbaa205c1d365a11e9dd0fc1f1d2c20e662df007c54d858893c13a36ca99ddbe9bb6e37c98dab54714b
|
data/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,13 @@ Note: this log contains only changes from knife-ec2 release 0.8.0 and later
|
|
|
4
4
|
-- it does not contain the changes from prior releases. To view change history
|
|
5
5
|
prior to release 0.8.0, please visit the [source repository](https://github.com/opscode/knife-ec2/commits).
|
|
6
6
|
|
|
7
|
-
## Latest
|
|
7
|
+
## Latest Release: 0.12.0 (2015-10-1)
|
|
8
|
+
|
|
9
|
+
* [knife-ec2:#305](https://github.com/chef/knife-ec2/pull/305) Updates to support standard .aws/credentials file
|
|
10
|
+
* [knife-ec2 #354](https://github.com/chef/knife-ec2/pull/354) knife-windows 1.0.0 dependency, support for validatorless bootstrap, other Chef 12 bootstrap options
|
|
11
|
+
* [knife-ec2 #356](https://github.com/chef/knife-ec2/pull/356) Added --forward-agent option
|
|
12
|
+
|
|
13
|
+
## Release: 0.11.0 (2015-08-24)
|
|
8
14
|
* [knife-ec2:#330](https://github.com/chef/knife-ec2/pull/330) Modification for attribute precedence issue
|
|
9
15
|
* [knife-ec2:#293](https://github.com/chef/knife-ec2/pull/293) s3_source: Lazy load fog library
|
|
10
16
|
* [knife-ec2:#284](https://github.com/chef/knife-ec2/pull/284) Enable Spot Pricing
|
data/DOC_CHANGES.md
CHANGED
|
@@ -4,65 +4,58 @@ This file is reset everytime when a new release is done. Contents of this file i
|
|
|
4
4
|
|
|
5
5
|
# knife-ec2 doc changes
|
|
6
6
|
|
|
7
|
-
Documentation changes are given below for **knife-ec2 version 0.
|
|
7
|
+
Documentation changes are given below for **knife-ec2 version 0.12.0**.
|
|
8
|
+
|
|
9
|
+
## `knife ec2 server create` subcommand changes
|
|
10
|
+
|
|
11
|
+
### SSH agent forwarding with --forward-agent option
|
|
12
|
+
The `--forward-agent` option has been added to the `knife ec2 server
|
|
13
|
+
create` subcommand. This enables SSH agent forwarding, and has the
|
|
14
|
+
same behavior during bootstrap of the created node as the
|
|
15
|
+
`--forward-agent` option of the [`knife bootstrap` subcommand](https://docs.chef.io/knife_bootstrap.html).
|
|
16
|
+
|
|
17
|
+
### WinRM security `--winrm-authentication-protocol` option
|
|
18
|
+
`knife-ec2`'s `server create` subcommand supports bootstrap via
|
|
19
|
+
the `WinRM` remote command protocol. The
|
|
20
|
+
`--winrm-authentication-protocol` option controls authentication to
|
|
21
|
+
the remote system (the bootstrapped node). This option's behavior is
|
|
22
|
+
covered in the
|
|
23
|
+
[knife-windows](https://github.com/chef/knife-windows/blob/v1.0.0/DOC_CHANGES.md)
|
|
24
|
+
subcommand documentation which has identically named option.
|
|
25
|
+
|
|
26
|
+
Note that with this change, the default authentication used for WinRM
|
|
27
|
+
communication specified by the `--winrm-authentication-protocol`
|
|
28
|
+
option is the `negotiate` protocol, which is different than that used
|
|
29
|
+
by previous versions of `knife-ec2`. This may lead to some
|
|
30
|
+
compatibility issues when using WinRM's plaintext transport
|
|
31
|
+
(`--winrm-transport` set to the default of `plaintext`) running from `knife ec2 server create`
|
|
32
|
+
from an operating system other than Windows.
|
|
33
|
+
|
|
34
|
+
To avoid problems with the `negotiate` protocol on a non-Windows
|
|
35
|
+
system, configure `--winrm-transport` to `ssl` to use SSL which also
|
|
36
|
+
improves the robustness against information disclosure or tampering
|
|
37
|
+
attacks.
|
|
38
|
+
|
|
39
|
+
You may also revert to previous authentication behavior by specifying `basic` for the
|
|
40
|
+
`--winrm-authentication-protocol` option. More details on this change
|
|
41
|
+
can be found in [documentation](https://github.com/chef/knife-windows/blob/v1.0.0/DOC_CHANGES.md#winrm-authentication-protocol-defaults-to-negotiate-regardless-of-name-formats) for `knife-windows`.
|
|
42
|
+
|
|
43
|
+
### Chef Client installation options on Windows
|
|
44
|
+
The following options are available for Windows systems:
|
|
45
|
+
|
|
46
|
+
* `--msi-url URL`: Optional. Used to override the location from which Chef
|
|
47
|
+
Client is downloaded. If not specified, Chef Client is downloaded
|
|
48
|
+
from the Internet -- this option allows downloading from a private network
|
|
49
|
+
location for instance.
|
|
50
|
+
* `--install-as-service`: Install chef-client as a service on Windows
|
|
51
|
+
systems
|
|
52
|
+
* `--bootstrap-install-command`: Optional. Instead of downloading Chef
|
|
53
|
+
Client and installing it using a default installation command,
|
|
54
|
+
bootstrap will invoke this command. If an image already has
|
|
55
|
+
Chef Client installed, this command can be specified as empty
|
|
56
|
+
(`''`), in which case no installation will be done and the rest of
|
|
57
|
+
bootstrap will proceed as if it's already installed.
|
|
58
|
+
|
|
59
|
+
For more detail, see the [knife-windows documentation](https://docs.chef.io/plugin_knife_windows.html).
|
|
8
60
|
|
|
9
|
-
## Provisioned IOPS support for `server create` command
|
|
10
61
|
|
|
11
|
-
Options are now available in the `knife ec2 server create` subcommand to
|
|
12
|
-
specify provisioned IOPS for the created instance.
|
|
13
|
-
|
|
14
|
-
### Option `--ebs-volume-type`
|
|
15
|
-
|
|
16
|
-
This command line option and associated plugin configuration `:ebs_volume_type` allow you to specify an EBS volume of type `standard` or `io1` as a `string` parameter to this option. The former is the default, the latter will allow the specification of a provisioned IOPS rate through the `--provisioned-iops` option.
|
|
17
|
-
|
|
18
|
-
### Option `--provisioned-iops`
|
|
19
|
-
This command line option and the associated `:ebs_provisioned_iops` plugin
|
|
20
|
-
configuration enables the EC2 instance to be configured with the specified
|
|
21
|
-
provisioned IOPS rate given as an argument to this option. It is only valid if
|
|
22
|
-
the EBS volume type is `io1` as specified by the `--ebs-volume-type` option
|
|
23
|
-
for this plugin.
|
|
24
|
-
|
|
25
|
-
## Use of secret parameters from S3 for `server create` command
|
|
26
|
-
|
|
27
|
-
The options below allow some secrets used with the `knife ec2 server create`
|
|
28
|
-
command to be specified as URL's. Examples are also given in the README.md.
|
|
29
|
-
|
|
30
|
-
### Option `--s3-secret`
|
|
31
|
-
This option allows the specification of an AWS S3 storage bucket that contains
|
|
32
|
-
a data bag secret file -- this option can be used in place of the
|
|
33
|
-
`secret_file` option. It takes an S3 URL as an argument (e.g.
|
|
34
|
-
`s3://bucket/file`) -- that file should contain encrypted data bag secret file
|
|
35
|
-
|
|
36
|
-
### Option `--validation-key-url`
|
|
37
|
-
This option allows the validation key to be specified as a URL. It takes a URL
|
|
38
|
-
as an argument.
|
|
39
|
-
|
|
40
|
-
## Option `--aws-session-token`
|
|
41
|
-
The option `--aws-session-token` was added for all knife-ec2 subcommands to
|
|
42
|
-
allow support for federation use cases utilizing EC2 STS tokens.
|
|
43
|
-
|
|
44
|
-
## SSH Gateway from SSH Config
|
|
45
|
-
Any available SSH Gateway settings in your SSH configuration file are now used
|
|
46
|
-
by default. This includes using any SSH keys specified for the target host.
|
|
47
|
-
This allows simpler command-line usage of the knife plugin with less of a need
|
|
48
|
-
for complex command line invocations.
|
|
49
|
-
|
|
50
|
-
## Support Spot Instances
|
|
51
|
-
You can now request a spot instance at a specific price.
|
|
52
|
-
|
|
53
|
-
### Option `--spot-price`
|
|
54
|
-
This option allows the maximum desired spot price to be specified. It takes a
|
|
55
|
-
price in US dollars.
|
|
56
|
-
|
|
57
|
-
## Pass separate SSH Gateway key
|
|
58
|
-
You can pass an SSH key to be used for authenticating to the SSH Gateway with
|
|
59
|
-
the --ssh-gateway-identity option.
|
|
60
|
-
|
|
61
|
-
### options
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
--aws-session-token
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Your AWS Session Token, for use with AWS STS Federation or Session Tokens.
|
|
68
|
-
This option is available for all subcommands.
|
data/README.md
CHANGED
|
@@ -87,6 +87,13 @@ this file in your <tt>knife.rb</tt> file, like so:
|
|
|
87
87
|
knife[:aws_credential_file] = "/path/to/credentials/file/in/above/format"
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
If you have multiple profiles in your credentials file you can define which
|
|
91
|
+
profile to use. The `default` profile will be used if not supplied,
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
knife[:aws_profile] = "personal"
|
|
95
|
+
```
|
|
96
|
+
|
|
90
97
|
Additionally the following options may be set in your `knife.rb`:
|
|
91
98
|
|
|
92
99
|
- flavor
|
|
@@ -153,6 +160,21 @@ Provisions a new server in the Amazon EC2 and then perform a Chef bootstrap
|
|
|
153
160
|
|
|
154
161
|
View additional information on configuring Windows images for bootstrap in the documentation for [knife-windows](http://docs.chef.io/plugin_knife_windows.html).
|
|
155
162
|
|
|
163
|
+
##### Options for bootstrapping Windows
|
|
164
|
+
|
|
165
|
+
The `knife ec2 server create` command also supports the following
|
|
166
|
+
options for bootstrapping a Windows node after the VM s created:
|
|
167
|
+
|
|
168
|
+
:winrm_password The WinRM password
|
|
169
|
+
:winrm_authentication_protocol Defaults to negotiate, supports kerberos, can be set to basic for debugging
|
|
170
|
+
:winrm_transport Defaults to plaintext, use ssl for improved privacy
|
|
171
|
+
:winrm_port Defaults to 5985 plaintext transport, or 5986 for SSL
|
|
172
|
+
:ca_trust_file The CA certificate file to use to verify the server when using SSL
|
|
173
|
+
:winrm_ssl_verify_mode Defaults to verify_peer, use verify_none to skip validation of the server certificate during testing
|
|
174
|
+
:kerberos_keytab_file The Kerberos keytab file used for authentication
|
|
175
|
+
:kerberos_realm The Kerberos realm used for authentication
|
|
176
|
+
:kerberos_service The Kerberos service used for authentication
|
|
177
|
+
|
|
156
178
|
#### `knife ec2 server delete`
|
|
157
179
|
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**
|
|
158
180
|
|
data/RELEASE_NOTES.md
CHANGED
|
@@ -6,33 +6,47 @@ Example Note:
|
|
|
6
6
|
## Example Heading
|
|
7
7
|
Details about the thing that changed that needs to get included in the Release Notes in markdown.
|
|
8
8
|
-->
|
|
9
|
-
# knife-ec2 0.
|
|
9
|
+
# knife-ec2 0.12.0 release notes:
|
|
10
|
+
|
|
10
11
|
This release of `knife-ec2` adds features like spot pricing, EBS volume encryption support and some bug fixes. There is also a dependency update for the `fog` gem and 'em-winrm' dependency is removed.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
## Compatibility note for Windows nodes: `--winrm-authentication-protocol basic`
|
|
14
|
+
In this version of `knife-ec2`, the default authentication protocol
|
|
15
|
+
for Windows nodes is now `negotiate`for the `server create` subcommand. This can
|
|
16
|
+
cause bootstraps to fail if the remote Windows node is not configured
|
|
17
|
+
for `negotiate`. To work around this and retain the behavior of
|
|
18
|
+
previous releases, you can specify use `basic` authentication in your
|
|
19
|
+
`knife` configuration file or on the command line as in
|
|
20
|
+
this example:
|
|
21
|
+
|
|
22
|
+
knife ec2 server create -I ami-173d747e -G windows -f m1.medium --user-data ~/your-user-data-file -x 'a_local_user' -P 'yourpassword' --ssh-key your-public-key-id --winrm-authentication-protocol basic
|
|
23
|
+
|
|
24
|
+
## Acknowledgements
|
|
25
|
+
Our thanks go to contributor **Peer Allan** for adding
|
|
26
|
+
[knife-ec2:#305](https://github.com/chef/knife-ec2/pull/305). This
|
|
27
|
+
enables the use of standard AWS credential configuration from `~/.aws/credentials`.
|
|
14
28
|
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
## Release information
|
|
30
|
+
|
|
31
|
+
See the [CHANGELOG](https://github.com/chef/knife-ec2/blob/0.12.0/CHANGELOG.md) for a list of all changes in this release, and review
|
|
32
|
+
[DOC_CHANGES.md](https://github.com/chef/knife-ec2/blob/0.12.0/DOC_CHANGES.md) for relevant documentation updates.
|
|
17
33
|
|
|
18
34
|
Issues with `knife-ec2` should be reported in the issue system at
|
|
19
35
|
https://github.com/opscode/knife-ec2/issues. Learn more about how you can
|
|
20
36
|
contribute features and bug fixes to `knife-ec2` at https://github.com/opscode/knife-ec2/blob/master/CONTRIBUTING.md.
|
|
21
37
|
|
|
22
|
-
## Features added in knife-ec2 0.
|
|
38
|
+
## Features added in knife-ec2 0.12.0
|
|
23
39
|
|
|
24
|
-
* Support for
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
40
|
+
* Support for `~/.aws/credentials` credential configuration (Peer Allan)
|
|
41
|
+
* Validatorless bootstrap for Windows nodes
|
|
42
|
+
* --forward-agent ssh agent forwarding support
|
|
43
|
+
* `--msi-url`, `--install-as-service`, `--bootstrap-install-command`
|
|
44
|
+
for Windows nodes
|
|
28
45
|
|
|
29
46
|
## knife-ec2 on RubyGems and Github
|
|
30
47
|
https://rubygems.org/gems/knife-ec2
|
|
31
48
|
https://github.com/opscode/knife-ec2
|
|
32
49
|
|
|
33
50
|
## Issues fixed in knife-ec2 0.11.0
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* Remove 'em-winrm' gem dependency
|
|
37
|
-
* [knife-ec2:#273](https://github.com/chef/knife-ec2/pull/273) Remove -s option for data bag secret and subnets
|
|
38
|
-
* [knife-ec2:#265](https://github.com/chef/knife-ec2/pull/265) showing error message for incorrect option input
|
|
51
|
+
See the [0.12.0 CHANGELOG](https://github.com/chef/knife-ec2/blob/0.12.0/CHANGELOG.md)
|
|
52
|
+
for the complete list of issues fixed in this release.
|
data/knife-ec2.gemspec
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
3
|
-
require 'knife-ec2/version'
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |s|
|
|
6
|
-
s.name = 'knife-ec2'
|
|
7
|
-
s.version = Knife::Ec2::VERSION
|
|
8
|
-
s.authors = ['Adam Jacob', 'Seth Chisamore']
|
|
9
|
-
s.email = ['adam@opscode.com', 'schisamo@opscode.com']
|
|
10
|
-
s.homepage = 'https://github.com/opscode/knife-ec2'
|
|
11
|
-
s.summary = "EC2 Support for Chef's Knife Command"
|
|
12
|
-
s.description = s.summary
|
|
13
|
-
s.license = 'Apache-2.0'
|
|
14
|
-
|
|
15
|
-
s.files = `git ls-files`.split("\n")
|
|
16
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
18
|
-
|
|
19
|
-
s.add_dependency 'fog', '~> 1.29.0'
|
|
20
|
-
s.add_dependency 'knife-windows', '
|
|
21
|
-
|
|
22
|
-
s.add_development_dependency 'chef', '~> 12.0', '>= 12.2.1'
|
|
23
|
-
s.add_development_dependency 'rspec', '~> 3.0'
|
|
24
|
-
s.add_development_dependency 'rake', '~> 10.1'
|
|
25
|
-
s.add_development_dependency 'sdoc', '~> 0.3'
|
|
26
|
-
|
|
27
|
-
s.require_paths = ['lib']
|
|
28
|
-
end
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'knife-ec2/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'knife-ec2'
|
|
7
|
+
s.version = Knife::Ec2::VERSION
|
|
8
|
+
s.authors = ['Adam Jacob', 'Seth Chisamore']
|
|
9
|
+
s.email = ['adam@opscode.com', 'schisamo@opscode.com']
|
|
10
|
+
s.homepage = 'https://github.com/opscode/knife-ec2'
|
|
11
|
+
s.summary = "EC2 Support for Chef's Knife Command"
|
|
12
|
+
s.description = s.summary
|
|
13
|
+
s.license = 'Apache-2.0'
|
|
14
|
+
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
18
|
+
|
|
19
|
+
s.add_dependency 'fog', '~> 1.29.0'
|
|
20
|
+
s.add_dependency 'knife-windows', '~> 1.0'
|
|
21
|
+
|
|
22
|
+
s.add_development_dependency 'chef', '~> 12.0', '>= 12.2.1'
|
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
|
24
|
+
s.add_development_dependency 'rake', '~> 10.1'
|
|
25
|
+
s.add_development_dependency 'sdoc', '~> 0.3'
|
|
26
|
+
|
|
27
|
+
s.require_paths = ['lib']
|
|
28
|
+
end
|
data/lib/chef/knife/ec2_base.rb
CHANGED
|
@@ -39,6 +39,12 @@ class Chef
|
|
|
39
39
|
:description => "File containing AWS credentials as used by aws cmdline tools",
|
|
40
40
|
:proc => Proc.new { |key| Chef::Config[:knife][:aws_credential_file] = key }
|
|
41
41
|
|
|
42
|
+
option :aws_profile,
|
|
43
|
+
:long => "--aws-profile PROFILE",
|
|
44
|
+
:description => "AWS profile, from credential file, to use",
|
|
45
|
+
:default => 'default',
|
|
46
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_profile] = key }
|
|
47
|
+
|
|
42
48
|
option :aws_access_key_id,
|
|
43
49
|
:short => "-A ID",
|
|
44
50
|
:long => "--aws-access-key-id KEY",
|
|
@@ -115,14 +121,14 @@ class Chef
|
|
|
115
121
|
# AWSAccessKeyId=somethingsomethingdarkside
|
|
116
122
|
# AWSSecretKey=somethingsomethingcomplete
|
|
117
123
|
# OR
|
|
124
|
+
# [default]
|
|
118
125
|
# aws_access_key_id = somethingsomethingdarkside
|
|
119
126
|
# aws_secret_access_key = somethingsomethingdarkside
|
|
120
127
|
|
|
121
|
-
aws_creds = []
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
entries = Hash[*aws_creds.flatten]
|
|
128
|
+
aws_creds = ini_parse(File.read(Chef::Config[:knife][:aws_credential_file]))
|
|
129
|
+
profile = Chef::Config[:knife][:aws_profile] || 'default'
|
|
130
|
+
entries = aws_creds.values.first.has_key?("AWSAccessKeyId") ? aws_creds.values.first : aws_creds[profile]
|
|
131
|
+
|
|
126
132
|
Chef::Config[:knife][:aws_access_key_id] = entries['AWSAccessKeyId'] || entries['aws_access_key_id']
|
|
127
133
|
Chef::Config[:knife][:aws_secret_access_key] = entries['AWSSecretKey'] || entries['aws_secret_access_key']
|
|
128
134
|
end
|
|
@@ -149,5 +155,24 @@ class Chef
|
|
|
149
155
|
end
|
|
150
156
|
name ||= ''
|
|
151
157
|
end
|
|
158
|
+
|
|
159
|
+
def ini_parse(file)
|
|
160
|
+
current_section = {}
|
|
161
|
+
map = {}
|
|
162
|
+
file.each_line do |line|
|
|
163
|
+
line = line.split(/^|\s;/).first # remove comments
|
|
164
|
+
section = line.match(/^\s*\[([^\[\]]+)\]\s*$/) unless line.nil?
|
|
165
|
+
if section
|
|
166
|
+
current_section = section[1]
|
|
167
|
+
elsif current_section
|
|
168
|
+
item = line.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/) unless line.nil?
|
|
169
|
+
if item
|
|
170
|
+
map[current_section] ||= {}
|
|
171
|
+
map[current_section][item[1]] = item[2]
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
map
|
|
176
|
+
end
|
|
152
177
|
end
|
|
153
178
|
end
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
require 'chef/knife/ec2_base'
|
|
21
21
|
require 'chef/knife/s3_source'
|
|
22
22
|
require 'chef/knife/winrm_base'
|
|
23
|
+
require 'chef/knife/bootstrap_windows_base'
|
|
23
24
|
|
|
24
25
|
class Chef
|
|
25
26
|
class Knife
|
|
@@ -27,6 +28,7 @@ class Chef
|
|
|
27
28
|
|
|
28
29
|
include Knife::Ec2Base
|
|
29
30
|
include Knife::WinrmBase
|
|
31
|
+
include Knife::BootstrapWindowsBase
|
|
30
32
|
deps do
|
|
31
33
|
require 'tempfile'
|
|
32
34
|
require 'fog'
|
|
@@ -385,6 +387,12 @@ class Chef
|
|
|
385
387
|
:description => "Execute the bootstrap via sudo with password",
|
|
386
388
|
:boolean => false
|
|
387
389
|
|
|
390
|
+
option :forward_agent,
|
|
391
|
+
:short => "-A",
|
|
392
|
+
:long => "--forward-agent",
|
|
393
|
+
:description => "Enable SSH agent forwarding",
|
|
394
|
+
:boolean => true
|
|
395
|
+
|
|
388
396
|
def run
|
|
389
397
|
$stdout.sync = true
|
|
390
398
|
|
|
@@ -678,6 +686,7 @@ class Chef
|
|
|
678
686
|
bootstrap.config[:ca_trust_file] = locate_config_value(:ca_trust_file)
|
|
679
687
|
bootstrap.config[:winrm_port] = locate_config_value(:winrm_port)
|
|
680
688
|
bootstrap.config[:auth_timeout] = locate_config_value(:auth_timeout)
|
|
689
|
+
bootstrap.config[:winrm_ssl_verify_mode] = locate_config_value(:winrm_ssl_verify_mode)
|
|
681
690
|
elsif locate_config_value(:bootstrap_protocol) == 'ssh'
|
|
682
691
|
bootstrap = Chef::Knife::BootstrapWindowsSsh.new
|
|
683
692
|
bootstrap.config[:ssh_user] = locate_config_value(:ssh_user)
|
|
@@ -685,11 +694,15 @@ class Chef
|
|
|
685
694
|
bootstrap.config[:ssh_port] = locate_config_value(:ssh_port)
|
|
686
695
|
bootstrap.config[:identity_file] = locate_config_value(:identity_file)
|
|
687
696
|
bootstrap.config[:no_host_key_verify] = locate_config_value(:no_host_key_verify)
|
|
697
|
+
bootstrap.config[:forward_agent] = locate_config_value(:forward_agent)
|
|
688
698
|
else
|
|
689
699
|
ui.error("Unsupported Bootstrapping Protocol. Supported : winrm, ssh")
|
|
690
700
|
exit 1
|
|
691
701
|
end
|
|
692
702
|
bootstrap.name_args = [fqdn]
|
|
703
|
+
bootstrap.config[:msi_url] = locate_config_value(:msi_url)
|
|
704
|
+
bootstrap.config[:install_as_service] = locate_config_value(:install_as_service)
|
|
705
|
+
bootstrap.config[:session_timeout] = locate_config_value(:session_timeout)
|
|
693
706
|
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
|
|
694
707
|
bootstrap_common_params(bootstrap)
|
|
695
708
|
end
|
|
@@ -1166,7 +1179,6 @@ class Chef
|
|
|
1166
1179
|
|
|
1167
1180
|
def load_winrm_deps
|
|
1168
1181
|
require 'winrm'
|
|
1169
|
-
require 'em-winrm'
|
|
1170
1182
|
require 'chef/knife/winrm'
|
|
1171
1183
|
require 'chef/knife/bootstrap_windows_winrm'
|
|
1172
1184
|
require 'chef/knife/bootstrap_windows_ssh'
|
data/lib/knife-ec2/version.rb
CHANGED
|
@@ -77,7 +77,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
77
77
|
:instance_id => 'test_spot_instance_id',
|
|
78
78
|
:state => 'open',
|
|
79
79
|
:key_name => 'ssh_key_name',
|
|
80
|
-
:availability_zone => nil,
|
|
80
|
+
:availability_zone => nil,
|
|
81
81
|
:flavor_id => 'm1.small',
|
|
82
82
|
:image_id => 'image' }
|
|
83
83
|
|
|
@@ -465,7 +465,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
465
465
|
@aws_key = Chef::Config[:knife][:aws_ssh_key_id]
|
|
466
466
|
allow(@knife_ec2_create).to receive(:ami).and_return(false)
|
|
467
467
|
end
|
|
468
|
-
|
|
468
|
+
|
|
469
469
|
it "gives warning message and creates the attribute with the required name" do
|
|
470
470
|
expect(@knife_ec2_create.ui).to receive(:warn).with("Use of aws_ssh_key_id option in knife.rb config is deprecated, use ssh_key_name option instead.")
|
|
471
471
|
@knife_ec2_create.validate!
|
|
@@ -479,7 +479,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
479
479
|
@aws_key = Chef::Config[:knife][:aws_ssh_key_id]
|
|
480
480
|
allow(@knife_ec2_create).to receive(:ami).and_return(false)
|
|
481
481
|
end
|
|
482
|
-
|
|
482
|
+
|
|
483
483
|
it "gives warning message and gives preference to CLI value over knife config's value" do
|
|
484
484
|
expect(@knife_ec2_create.ui).to receive(:warn).with("Use of aws_ssh_key_id option in knife.rb config is deprecated, use ssh_key_name option instead.")
|
|
485
485
|
@knife_ec2_create.validate!
|
|
@@ -492,7 +492,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
492
492
|
Chef::Config[:knife][:ssh_key_name] = "mykey"
|
|
493
493
|
allow(@knife_ec2_create).to receive(:ami).and_return(false)
|
|
494
494
|
end
|
|
495
|
-
|
|
495
|
+
|
|
496
496
|
it "does nothing" do
|
|
497
497
|
@knife_ec2_create.validate!
|
|
498
498
|
end
|
|
@@ -504,7 +504,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
504
504
|
Chef::Config[:knife][:ssh_key_name] = "mykey"
|
|
505
505
|
@knife_ec2_create.config[:ssh_key_name] = "ssh_key_name"
|
|
506
506
|
end
|
|
507
|
-
|
|
507
|
+
|
|
508
508
|
it "ssh-key passed over CLI gets preference over knife config value" do
|
|
509
509
|
server_def = @knife_ec2_create.create_server_def
|
|
510
510
|
expect(server_def[:key_name]).to eq(@knife_ec2_create.config[:ssh_key_name])
|
|
@@ -595,6 +595,25 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
595
595
|
expect(Chef::Config[:knife][:hints]["ec2"]).not_to be_nil
|
|
596
596
|
end
|
|
597
597
|
end
|
|
598
|
+
|
|
599
|
+
describe "when configuring the ssh bootstrap process for windows" do
|
|
600
|
+
before do
|
|
601
|
+
allow(@knife_ec2_create).to receive(:fetch_server_fqdn).and_return("SERVERNAME")
|
|
602
|
+
@knife_ec2_create.config[:ssh_user] = "administrator"
|
|
603
|
+
@knife_ec2_create.config[:ssh_password] = "password"
|
|
604
|
+
@knife_ec2_create.config[:ssh_port] = 22
|
|
605
|
+
@knife_ec2_create.config[:forward_agent] = true
|
|
606
|
+
@knife_ec2_create.config[:bootstrap_protocol] = 'ssh'
|
|
607
|
+
@knife_ec2_create.config[:image] = '12345'
|
|
608
|
+
allow(@knife_ec2_create).to receive(:is_image_windows?).and_return(true)
|
|
609
|
+
@bootstrap = @knife_ec2_create.bootstrap_for_windows_node(@new_ec2_server, @new_ec2_server.dns_name)
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
it "sets the bootstrap 'forward_agent' correctly" do
|
|
613
|
+
expect(@bootstrap.config[:forward_agent]).to eq(true)
|
|
614
|
+
end
|
|
615
|
+
end
|
|
616
|
+
|
|
598
617
|
describe "when configuring the winrm bootstrap process for windows" do
|
|
599
618
|
before do
|
|
600
619
|
allow(@knife_ec2_create).to receive(:fetch_server_fqdn).and_return("SERVERNAME")
|
|
@@ -610,6 +629,10 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
610
629
|
@knife_ec2_create.config[:distro] = 'ubuntu-10.04-magic-sparkles'
|
|
611
630
|
@knife_ec2_create.config[:run_list] = ['role[base]']
|
|
612
631
|
@knife_ec2_create.config[:json_attributes] = "{'my_attributes':{'foo':'bar'}"
|
|
632
|
+
@knife_ec2_create.config[:winrm_ssl_verify_mode] = 'basic'
|
|
633
|
+
@knife_ec2_create.config[:msi_url] = 'https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-client-12.3.0-1.msi'
|
|
634
|
+
@knife_ec2_create.config[:install_as_service] = true
|
|
635
|
+
@knife_ec2_create.config[:session_timeout] = "90"
|
|
613
636
|
@bootstrap = @knife_ec2_create.bootstrap_for_windows_node(@new_ec2_server, @new_ec2_server.dns_name)
|
|
614
637
|
end
|
|
615
638
|
|
|
@@ -655,6 +678,22 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
655
678
|
expect(@bootstrap.config[:first_boot_attributes]).to eq("{'my_attributes':{'foo':'bar'}")
|
|
656
679
|
end
|
|
657
680
|
|
|
681
|
+
it "should set the bootstrap 'winrm_ssl_verify_mode' correctly" do
|
|
682
|
+
expect(@bootstrap.config[:winrm_ssl_verify_mode]).to eq("basic")
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
it "should set the bootstrap 'msi_url' correctly" do
|
|
686
|
+
expect(@bootstrap.config[:msi_url]).to eq('https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-client-12.3.0-1.msi')
|
|
687
|
+
end
|
|
688
|
+
|
|
689
|
+
it "should set the bootstrap 'install_as_service' correctly" do
|
|
690
|
+
expect(@bootstrap.config[:install_as_service]).to eq(@knife_ec2_create.config[:install_as_service])
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
it "should set the bootstrap 'session_timeout' correctly" do
|
|
694
|
+
expect(@bootstrap.config[:session_timeout]).to eq(@knife_ec2_create.config[:session_timeout])
|
|
695
|
+
end
|
|
696
|
+
|
|
658
697
|
it "configures sets the bootstrap's run_list" do
|
|
659
698
|
expect(@bootstrap.config[:run_list]).to eq(['role[base]'])
|
|
660
699
|
end
|
|
@@ -704,7 +743,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
704
743
|
end
|
|
705
744
|
it "reads UNIX Line endings for new format" do
|
|
706
745
|
allow(File).to receive(:read).
|
|
707
|
-
and_return("
|
|
746
|
+
and_return("[default]\naws_access_key_id=#{@access_key_id}\naws_secret_access_key=#{@secret_key}")
|
|
708
747
|
@knife_ec2_create.validate!
|
|
709
748
|
expect(Chef::Config[:knife][:aws_access_key_id]).to eq(@access_key_id)
|
|
710
749
|
expect(Chef::Config[:knife][:aws_secret_access_key]).to eq(@secret_key)
|
|
@@ -712,7 +751,16 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
712
751
|
|
|
713
752
|
it "reads DOS Line endings for new format" do
|
|
714
753
|
allow(File).to receive(:read).
|
|
715
|
-
and_return("
|
|
754
|
+
and_return("[default]\naws_access_key_id=#{@access_key_id}\r\naws_secret_access_key=#{@secret_key}")
|
|
755
|
+
@knife_ec2_create.validate!
|
|
756
|
+
expect(Chef::Config[:knife][:aws_access_key_id]).to eq(@access_key_id)
|
|
757
|
+
expect(Chef::Config[:knife][:aws_secret_access_key]).to eq(@secret_key)
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
it "loads the correct profile" do
|
|
761
|
+
Chef::Config[:knife][:aws_profile] = 'other'
|
|
762
|
+
allow(File).to receive(:read).
|
|
763
|
+
and_return("[default]\naws_access_key_id=TESTKEY\r\naws_secret_access_key=TESTSECRET\n\n[other]\naws_access_key_id=#{@access_key_id}\r\naws_secret_access_key=#{@secret_key}")
|
|
716
764
|
@knife_ec2_create.validate!
|
|
717
765
|
expect(Chef::Config[:knife][:aws_access_key_id]).to eq(@access_key_id)
|
|
718
766
|
expect(Chef::Config[:knife][:aws_secret_access_key]).to eq(@secret_key)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: knife-ec2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2015-
|
|
12
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: fog
|
|
@@ -29,16 +29,16 @@ dependencies:
|
|
|
29
29
|
name: knife-windows
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- - "
|
|
32
|
+
- - "~>"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 0
|
|
34
|
+
version: '1.0'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
|
-
- - "
|
|
39
|
+
- - "~>"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: 0
|
|
41
|
+
version: '1.0'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: chef
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
153
153
|
version: '0'
|
|
154
154
|
requirements: []
|
|
155
155
|
rubyforge_project:
|
|
156
|
-
rubygems_version: 2.4.
|
|
156
|
+
rubygems_version: 2.4.8
|
|
157
157
|
signing_key:
|
|
158
158
|
specification_version: 4
|
|
159
159
|
summary: EC2 Support for Chef's Knife Command
|