knife-ec2 0.18.2 → 0.19.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.expeditor/config.yml +13 -16
- data/.github/CODEOWNERS +4 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- data/.gitignore +0 -1
- data/.rspec +2 -0
- data/.rubocop.yml +30 -0
- data/.travis.yml +10 -17
- data/CHANGELOG.md +29 -7
- data/DOC_CHANGES.md +2 -12
- data/Gemfile +26 -2
- data/README.md +72 -75
- data/RELEASE_NOTES.md +10 -0
- data/Rakefile +25 -26
- data/VERSION +1 -1
- data/knife-ec2.gemspec +13 -20
- data/lib/chef/knife/ec2_ami_list.rb +31 -34
- data/lib/chef/knife/ec2_base.rb +137 -94
- data/lib/chef/knife/ec2_flavor_list.rb +12 -13
- data/lib/chef/knife/ec2_server_create.rb +440 -461
- data/lib/chef/knife/ec2_server_delete.rb +43 -41
- data/lib/chef/knife/ec2_server_list.rb +31 -28
- data/lib/chef/knife/s3_source.rb +22 -3
- data/lib/knife-ec2/version.rb +2 -2
- data/spec/spec_helper.rb +10 -11
- data/spec/unit/ec2_ami_list_spec.rb +297 -297
- data/spec/unit/ec2_flavor_list_spec.rb +18 -18
- data/spec/unit/ec2_server_create_spec.rb +952 -951
- data/spec/unit/ec2_server_delete_spec.rb +60 -61
- data/spec/unit/ec2_server_list_spec.rb +28 -28
- data/spec/unit/s3_source_deps_spec.rb +7 -7
- data/spec/unit/s3_source_spec.rb +17 -17
- metadata +26 -79
- data/CONTRIBUTING.md +0 -245
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 210fda04e631953dc8b84274ed591ecac3e227d8d2580b945e67c839c3d74933
|
4
|
+
data.tar.gz: 3d3823d890a88338bd47b26e117429a84fdd3a96573f568a96bf04a19585d62d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60e078f29f93de0ac1a3646b0a1753dacb8e0f354a7305d0019fe3a123d4151bc3b20b1ee21e297d4d5c19e353fdd3838d715391a23b1a08d3202c329f79d220
|
7
|
+
data.tar.gz: 52e6175ceb27c8d1e6edc080ee534d1dd6027d47d4c47ef1a92703116b502fd3700f16f4dbf96d5368df7ab7384af1d246404142558bb997e93cd94126f5f6d9
|
data/.expeditor/config.yml
CHANGED
@@ -1,41 +1,38 @@
|
|
1
|
-
# Documentation available at
|
2
|
-
|
1
|
+
# Documentation available at https://expeditor.chef.io/docs/getting-started/
|
2
|
+
---
|
3
3
|
# Slack channel in Chef Software slack to send notifications about build failures, etc
|
4
4
|
slack:
|
5
5
|
notify_channel: sustaining-notify
|
6
6
|
|
7
|
+
# This publish is triggered by the `built_in:publish_rubygems` artifact_action.
|
7
8
|
rubygems:
|
8
9
|
- knife-ec2
|
9
10
|
|
10
11
|
github:
|
12
|
+
# This deletes the GitHub PR branch after successfully merged into the release branch
|
13
|
+
delete_branch_on_merge: true
|
11
14
|
# The tag format to use (e.g. v1.0.0)
|
12
15
|
version_tag_format: "v{{version}}"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# for building.
|
17
|
-
release_branch:
|
18
|
-
- master:
|
19
|
-
version_constraint: 0.*
|
20
|
-
|
21
|
-
promote:
|
22
|
-
action:
|
23
|
-
- built_in:publish_rubygems
|
24
|
-
- built_in:rollover_changelog
|
16
|
+
# allow bumping the minor release via label
|
17
|
+
minor_bump_labels:
|
18
|
+
- "Expeditor: Bump Minor Version"
|
25
19
|
|
26
20
|
# These actions are taken, in order they are specified, anytime a Pull Request is merged.
|
27
21
|
merge_actions:
|
28
22
|
- built_in:bump_version:
|
29
23
|
ignore_labels:
|
30
|
-
- "Version: Skip Bump"
|
31
24
|
- "Expeditor: Skip Version Bump"
|
32
25
|
- "Expeditor: Skip All"
|
33
26
|
- bash:.expeditor/update_version.sh:
|
34
27
|
only_if: built_in:bump_version
|
35
28
|
- built_in:update_changelog:
|
36
29
|
ignore_labels:
|
37
|
-
- "Meta: Exclude From Changelog"
|
38
30
|
- "Expeditor: Exclude From Changelog"
|
39
31
|
- "Expeditor: Skip All"
|
40
32
|
- built_in:build_gem:
|
41
33
|
only_if: built_in:bump_version
|
34
|
+
|
35
|
+
promote:
|
36
|
+
actions:
|
37
|
+
- built_in:rollover_changelog
|
38
|
+
- built_in:publish_rubygems
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
### Description
|
2
|
+
|
3
|
+
[Please describe what this change achieves]
|
4
|
+
|
5
|
+
### Issues Resolved
|
6
|
+
|
7
|
+
[List any existing issues this PR resolves, or any Discourse or
|
8
|
+
StackOverflow discussion that's relevant]
|
9
|
+
|
10
|
+
### Check List
|
11
|
+
|
12
|
+
- [ ] New functionality includes tests
|
13
|
+
- [ ] All tests pass
|
14
|
+
- [ ] All commits have been signed-off for the Developer Certificate of Origin. See <https://github.com/chef/chef/blob/master/CONTRIBUTING.md#developer-certification-of-origin-dco>
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Lint/AssignmentInCondition:
|
2
|
+
Exclude:
|
3
|
+
- 'lib/chef/knife/ec2_server_create.rb'
|
4
|
+
|
5
|
+
Lint/EmptyWhen:
|
6
|
+
Exclude:
|
7
|
+
- 'lib/chef/knife/ec2_server_create.rb'
|
8
|
+
|
9
|
+
Lint/ParenthesesAsGroupedExpression:
|
10
|
+
Exclude:
|
11
|
+
- 'lib/chef/knife/ec2_base.rb'
|
12
|
+
- 'lib/chef/knife/ec2_server_create.rb'
|
13
|
+
- 'spec/unit/ec2_ami_list_spec.rb'
|
14
|
+
- 'spec/unit/ec2_server_create_spec.rb'
|
15
|
+
|
16
|
+
Lint/ShadowingOuterLocalVariable:
|
17
|
+
Exclude:
|
18
|
+
- 'lib/chef/knife/ec2_server_create.rb'
|
19
|
+
- 'lib/chef/knife/ec2_server_delete.rb'
|
20
|
+
|
21
|
+
Lint/UselessAssignment:
|
22
|
+
Exclude:
|
23
|
+
- 'lib/chef/knife/ec2_base.rb'
|
24
|
+
- 'lib/chef/knife/ec2_server_list.rb'
|
25
|
+
- 'spec/unit/ec2_ami_list_spec.rb'
|
26
|
+
|
27
|
+
Style/NumericPredicate:
|
28
|
+
Exclude:
|
29
|
+
- 'spec/**/*'
|
30
|
+
- 'lib/chef/knife/ec2_server_create.rb'
|
data/.travis.yml
CHANGED
@@ -1,27 +1,20 @@
|
|
1
|
+
sudo: false
|
1
2
|
language: ruby
|
2
3
|
cache: bundler
|
3
|
-
dist: trusty
|
4
|
-
sudo: false
|
5
4
|
|
6
|
-
# Early warning system to catch if Rubygems breaks something
|
7
|
-
before_install:
|
8
|
-
- gem update --system
|
9
|
-
- gem uninstall bundler -a -x
|
10
|
-
- gem install bundler
|
11
|
-
- rm -f .bundle/config
|
12
|
-
|
13
|
-
rvm:
|
14
|
-
- 2.2.7
|
15
|
-
- 2.3.4
|
16
|
-
- 2.4.1
|
17
|
-
- ruby-head
|
18
|
-
|
19
5
|
matrix:
|
6
|
+
include:
|
7
|
+
- rvm: 2.3.7
|
8
|
+
- rvm: 2.4.4
|
9
|
+
- rvm: 2.5.1
|
10
|
+
- rvm: ruby-head
|
20
11
|
allow_failures:
|
21
12
|
- rvm: ruby-head
|
22
13
|
|
23
|
-
script: bundle exec rake spec
|
24
|
-
|
25
14
|
branches:
|
26
15
|
only:
|
27
16
|
- master
|
17
|
+
|
18
|
+
bundler_args: --without docs development
|
19
|
+
|
20
|
+
script: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -4,24 +4,46 @@ 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/chef/knife-ec2/commits).
|
6
6
|
|
7
|
-
<!-- latest_release 0.
|
8
|
-
## [v0.
|
7
|
+
<!-- latest_release 0.19.10 -->
|
8
|
+
## [v0.19.10](https://github.com/chef/knife-ec2/tree/v0.19.10) (2018-08-06)
|
9
9
|
|
10
10
|
#### Merged Pull Requests
|
11
|
-
-
|
11
|
+
- If no keys specified on CLI/config use an AWS credential file if present [#548](https://github.com/chef/knife-ec2/pull/548) ([tas50](https://github.com/tas50))
|
12
12
|
<!-- latest_release -->
|
13
13
|
|
14
|
-
<!-- release_rollup since=0.18.
|
15
|
-
### Changes since 0.18.
|
14
|
+
<!-- release_rollup since=0.18.2 -->
|
15
|
+
### Changes since 0.18.2 release
|
16
16
|
|
17
17
|
#### Merged Pull Requests
|
18
|
-
-
|
19
|
-
-
|
18
|
+
- If no keys specified on CLI/config use an AWS credential file if present [#548](https://github.com/chef/knife-ec2/pull/548) ([tas50](https://github.com/tas50)) <!-- 0.19.10 -->
|
19
|
+
- Remove executables from gemspec and cleanup test files [#549](https://github.com/chef/knife-ec2/pull/549) ([tas50](https://github.com/tas50)) <!-- 0.19.9 -->
|
20
|
+
- Remove mime-types dependency [#550](https://github.com/chef/knife-ec2/pull/550) ([tas50](https://github.com/tas50)) <!-- 0.19.8 -->
|
21
|
+
- Remove readline dep which we're not using [#547](https://github.com/chef/knife-ec2/pull/547) ([tas50](https://github.com/tas50)) <!-- 0.19.7 -->
|
22
|
+
- Removed deprecated options distro and template_file flags in server create command [#542](https://github.com/chef/knife-ec2/pull/542) ([tas50](https://github.com/tas50)) <!-- 0.19.6 -->
|
23
|
+
- Provide a unique console color for us-east-1f availability zone [#541](https://github.com/chef/knife-ec2/pull/541) ([tas50](https://github.com/tas50)) <!-- 0.19.5 -->
|
24
|
+
- Improve the AMI missing error and improve the readme example [#543](https://github.com/chef/knife-ec2/pull/543) ([tas50](https://github.com/tas50)) <!-- 0.19.4 -->
|
25
|
+
- Lazy load deps and avoid double loading [#544](https://github.com/chef/knife-ec2/pull/544) ([tas50](https://github.com/tas50)) <!-- 0.19.3 -->
|
26
|
+
- Allow for fog-aws 1.0 - 3.0 dep to bring in bugfixes and new region support [#545](https://github.com/chef/knife-ec2/pull/545) ([tas50]
|
27
|
+
- Clarify which AWS CLI tools we're talking about [#540](https://github.com/chef/knife-ec2/pull/540) ([tas50](https://github.com/tas50)) <!-- 0.19.2 -->
|
28
|
+
- Fix knife ami list --group flag description [#539](https://github.com/chef/knife-ec2/pull/539) ([tas50](https://github.com/tas50)) <!-- 0.19.1 -->
|
29
|
+
- Rewrite the credentials section of the readme with new recommendations [#538](https://github.com/chef/knife-ec2/pull/538) ([tas50](https://github.com/tas50)) <!-- 0.19.0 -->
|
30
|
+
- Update installation instructions in the readme to push ChefDK [#537](https://github.com/chef/knife-ec2/pull/537) ([tas50](https://github.com/tas50)) <!-- 0.18.7 -->
|
31
|
+
- Add codeowners and PR template files [#533](https://github.com/chef/knife-ec2/pull/533) ([tas50](https://github.com/tas50)) <!-- 0.18.6 -->
|
32
|
+
- Move contributing docs out of the repo [#535](https://github.com/chef/knife-ec2/pull/535) ([tas50](https://github.com/tas50)) <!-- 0.18.5 -->
|
33
|
+
- Bump copyrights & minor readme updates [#532](https://github.com/chef/knife-ec2/pull/532) ([tas50](https://github.com/tas50)) <!-- 0.18.4 -->
|
34
|
+
- Drop Ruby 2.2 + Add Chefstyle + align testing with other projects [#530](https://github.com/chef/knife-ec2/pull/530) ([tas50](https://github.com/tas50)) <!-- 0.18.3 -->
|
20
35
|
<!-- release_rollup -->
|
21
36
|
|
22
37
|
<!-- latest_stable_release -->
|
38
|
+
## [v0.18.2](https://github.com/chef/knife-ec2/tree/v0.18.2) (2018-07-06)
|
39
|
+
|
40
|
+
#### Merged Pull Requests
|
41
|
+
- [MSYS-824] fix breaking tag changes & deprecation warning [#527](https://github.com/chef/knife-ec2/pull/527) ([dheerajd-msys](https://github.com/dheerajd-msys))
|
42
|
+
- MSYS-798 - Fixes for windows administrator password [#524](https://github.com/chef/knife-ec2/pull/524) ([dheerajd-msys](https://github.com/dheerajd-msys))
|
23
43
|
<!-- latest_stable_release -->
|
24
44
|
|
45
|
+
|
46
|
+
|
25
47
|
## Latest Release 0.18.0 (2018-04-05)
|
26
48
|
* [knife-ec2:#520](https://github.com/chef/knife-ec2/pull/520) Options `--aws-tag` and `--chef-tag` are added for tagging EC2 instance in AWS and Chef separately.
|
27
49
|
|
data/DOC_CHANGES.md
CHANGED
@@ -1,17 +1,7 @@
|
|
1
1
|
<!---
|
2
|
-
This file is reset
|
2
|
+
This file is reset every time when a new release is done. Contents of this file is for the currently unreleased version.
|
3
3
|
-->
|
4
4
|
|
5
5
|
# knife-ec2 doc changes
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
## `knife ec2 server create` subcommand changes
|
10
|
-
|
11
|
-
### `--aws-tag` option
|
12
|
-
|
13
|
-
The `--aws-tag` option is used for tagging the EC2 instances in AWS as `key=value` pair. Use this option like e.g. `--aws-tag <key1=value1>`. Multiple tags can be added by specifying the option multiple times.
|
14
|
-
|
15
|
-
### `--chef-tag` option
|
16
|
-
|
17
|
-
The `--chef-tag` option is used for tagging the EC2 instances on the Chef server. Use this option like e.g. `--chef-tag <myTag>`. Multiple tags can be added by specifying the option multiple times.
|
7
|
+
## 0.19.0
|
data/Gemfile
CHANGED
@@ -1,4 +1,28 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
2
3
|
gemspec
|
3
4
|
|
4
|
-
|
5
|
+
group :docs do
|
6
|
+
gem "yard"
|
7
|
+
gem "redcarpet"
|
8
|
+
gem "github-markup"
|
9
|
+
end
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
|
13
|
+
gem "rspec", "~> 3.0"
|
14
|
+
gem "rake"
|
15
|
+
gem "chef", ">= 13.0"
|
16
|
+
end
|
17
|
+
|
18
|
+
group :development do
|
19
|
+
gem "pry"
|
20
|
+
gem "pry-byebug"
|
21
|
+
gem "pry-stack_explorer"
|
22
|
+
end
|
23
|
+
|
24
|
+
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
25
|
+
|
26
|
+
# If you want to load debugging tools into the bundle exec sandbox,
|
27
|
+
# add these additional dependencies into Gemfile.local
|
28
|
+
eval_gemfile(__FILE__ + ".local") if File.exist?(__FILE__ + ".local")
|
data/README.md
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
# Knife EC2
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/knife-ec2.svg)](https://rubygems.org/gems/knife-ec2)
|
3
3
|
[![Build Status](https://travis-ci.org/chef/knife-ec2.svg?branch=master)](https://travis-ci.org/chef/knife-ec2)
|
4
|
-
[![Dependency Status](https://gemnasium.com/chef/knife-ec2.svg)](https://gemnasium.com/chef/knife-ec2)
|
5
4
|
|
6
5
|
This is the official Chef Knife plugin for Amazon EC2. This plugin gives knife the ability to create, bootstrap, and manage EC2 instances.
|
7
6
|
- Documentation: [https://github.com/chef/knife-ec2/blob/master/README.md](https://github.com/chef/knife-ec2/blob/master/README.md)
|
8
7
|
- Source: [https://github.com/chef/knife-ec2/tree/master](https://github.com/chef/knife-ec2/tree/master)
|
9
8
|
- Issues: [https://github.com/chef/knife-ec2/issues](https://github.com/chef/knife-ec2/issues)
|
10
|
-
- IRC: `#chef` and `#chef-hacking` on Freenode
|
11
9
|
- Mailing list: [https://discourse.chef.io/](https://discourse.chef.io/)
|
12
10
|
|
13
11
|
## Installation
|
14
|
-
If you're using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the Gem:
|
15
12
|
|
16
|
-
|
17
|
-
$ chef gem install knife-ec2
|
18
|
-
```
|
13
|
+
We highly recommend using [ChefDK](https://downloads.chef.io/chef-dk/), which includes knife-ec2 out of the box. If for some reason you can't use ChefDK you can manually install the gem.
|
19
14
|
|
20
15
|
If you're using bundler, simply add Chef and Knife EC2 to your `Gemfile`:
|
21
16
|
|
@@ -32,67 +27,36 @@ $ gem install knife-ec2
|
|
32
27
|
Depending on your system's configuration, you may need to run this command with root privileges.
|
33
28
|
|
34
29
|
## Configuration
|
35
|
-
In order to communicate with the Amazon's EC2 API you will need to pass Knife your AWS Access Key, Secret Access Key, and if using STS your session token. This can be done in several ways:
|
36
|
-
|
37
|
-
### Knife.rb Configuration
|
38
|
-
The easiest way to configure your Amazon EC2 credentials for knife-ec2 is to specify them in your your `knife.rb` file:
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
knife[:aws_access_key_id] = "Your AWS Access Key ID"
|
42
|
-
knife[:aws_secret_access_key] = "Your AWS Secret Access Key"
|
43
|
-
```
|
44
|
-
|
45
|
-
Additionally if using AWS STS:
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
knife[:aws_session_token] = "Your AWS Session Token"
|
49
|
-
```
|
50
|
-
|
51
|
-
Note: If your `knife.rb` file will be checked into a source control management system, or is otherwise accessible by others, you may want to use one of the other configuration methods to avoid exposing your credentials.
|
52
|
-
|
53
|
-
### Environmental Variables
|
54
|
-
Knife-ec2 can also read your credentials from shell environmental variables. Export `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables in your shell then add the following configuration to your `knife.rb` file:
|
55
|
-
|
56
|
-
```ruby
|
57
|
-
knife[:aws_access_key_id] = ENV['AWS_ACCESS_KEY_ID']
|
58
|
-
knife[:aws_secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY']
|
59
|
-
```
|
60
30
|
|
61
|
-
|
31
|
+
In order to communicate with the Amazon's EC2 API you will need to pass Knife your AWS Access Key, Secret Access Key, and if using STS your session token. The knife-ec2 plugin supports multiple methods for configuring these credentials including:
|
32
|
+
- AWS configuration / credential files (preferred method)
|
33
|
+
- knife.rb / config.rb configuration files
|
34
|
+
- environmental variables
|
35
|
+
- command line arguments
|
62
36
|
|
63
|
-
|
64
|
-
knife[:aws_session_token] = ENV['AWS_SESSION_TOKEN']
|
65
|
-
```
|
37
|
+
### AWS Configuration / Credential Files
|
66
38
|
|
67
|
-
|
68
|
-
You also have the option of passing your AWS API Key/Secret into the individual knife subcommands using the `--aws-access-key-id` and `--aws-secret-access-key` command options
|
39
|
+
The preferred method of storing credentials for AWS is to use Amazon's own credential and configuration files. The files allow for multiple "profiles", each with their own set of credentials. Also since these credentials aren't stored in your knife.rb/config.rb files you don't have to worry about accidentally checking credentials into a git repository. The configs can be created by hand or generated automatically by running `aws configure` if the AWS Command Line Interface (awscli) is installed.
|
69
40
|
|
70
|
-
Example of provisioning a new t2.micro Ubuntu 14.04 webserver:
|
71
41
|
|
72
|
-
|
73
|
-
$ knife ec2 server create -r 'role[webserver]' -I ami-cd0fd6be -f t2.micro --aws-access-key-id 'Your AWS Access Key ID' --aws-secret-access-key "Your AWS Secret Access Key"
|
74
|
-
```
|
42
|
+
See Amazon's [Configuration and Credentials Files](https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html) documentation for additional information on the file format and default locations for Linux/Mac & Windows hosts.
|
75
43
|
|
76
|
-
|
77
|
-
Amazon's newer credential config file format is also supported by knife:
|
44
|
+
#### Alternative Config Files Location
|
78
45
|
|
79
|
-
|
80
|
-
[default]
|
81
|
-
aws_access_key_id = Your AWS Access Key ID
|
82
|
-
aws_secret_access_key = Your AWS Secret Access Key
|
83
|
-
```
|
84
|
-
|
85
|
-
In this case, you can point the `aws_credential_file` option to this file in your `knife.rb` file, like so:
|
46
|
+
If you're not storing the files in their default directory you'll need to specify the location in your `knife.rb`/`config.rb` files:
|
86
47
|
|
87
48
|
```ruby
|
88
49
|
knife[:aws_credential_file] = "/path/to/credentials/file"
|
50
|
+
knife[:aws_config_file] = "/path/to/configuration/file"
|
89
51
|
```
|
90
52
|
Since the Knife config file is just Ruby you can also avoid hardcoding your home directory, which creates a configuration that can be used for any user:
|
91
53
|
|
92
54
|
```ruby
|
93
55
|
knife[:aws_credential_file] = File.join(ENV['HOME'], "/.aws/credentials")
|
56
|
+
knife[:aws_config_file] = File.join(ENV['HOME'], "/path/to/configuration/file")
|
94
57
|
```
|
95
58
|
|
59
|
+
#### Specifying the AWS Profile
|
96
60
|
|
97
61
|
If you have multiple profiles in your credentials file you can define which profile to use. The `default` profile will be used if not supplied,
|
98
62
|
|
@@ -100,40 +64,52 @@ If you have multiple profiles in your credentials file you can define which prof
|
|
100
64
|
knife[:aws_profile] = "personal"
|
101
65
|
```
|
102
66
|
|
103
|
-
###
|
104
|
-
Amazon's newer configuration file format is also supported by knife:
|
105
|
-
|
106
|
-
```
|
107
|
-
[default]
|
108
|
-
region = "specify_any_supported_region"
|
109
|
-
```
|
67
|
+
### Config.rb / Knife.rb Configuration
|
110
68
|
|
111
|
-
|
69
|
+
If you prefer to keep all of your configuration in a single location with Chef you can store your Amazon EC2 credentials in Chef's `knife.rb` or `config.rb` files:
|
112
70
|
|
113
71
|
```ruby
|
114
|
-
knife[:
|
72
|
+
knife[:aws_access_key_id] = "Your AWS Access Key ID"
|
73
|
+
knife[:aws_secret_access_key] = "Your AWS Secret Access Key"
|
115
74
|
```
|
116
|
-
|
75
|
+
|
76
|
+
Additionally if using AWS STS:
|
117
77
|
|
118
78
|
```ruby
|
119
|
-
knife[:
|
79
|
+
knife[:aws_session_token] = "Your AWS Session Token"
|
120
80
|
```
|
121
81
|
|
82
|
+
Note: If your `knife.rb` or `config.rb` files will be checked into a source control management system, or are otherwise accessible by others, you may want to use one of the other configuration methods to avoid exposing your credentials.
|
83
|
+
|
84
|
+
### Environmental Variables
|
122
85
|
|
123
|
-
|
86
|
+
Knife-ec2 can also read your credentials from shell environmental variables. Export `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables in your shell then add the following configuration to your `knife.rb` file:
|
124
87
|
|
125
88
|
```ruby
|
126
|
-
knife[:
|
89
|
+
knife[:aws_access_key_id] = ENV['AWS_ACCESS_KEY_ID']
|
90
|
+
knife[:aws_secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY']
|
127
91
|
```
|
128
92
|
|
129
|
-
|
93
|
+
Additionally if using AWS STS:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
knife[:aws_session_token] = ENV['AWS_SESSION_TOKEN']
|
130
97
|
```
|
131
|
-
|
132
|
-
|
98
|
+
|
99
|
+
### CLI Arguments
|
100
|
+
|
101
|
+
You also have the option of passing your AWS API Key/Secret into the individual knife subcommands using the `--aws-access-key-id` and `--aws-secret-access-key` command options
|
102
|
+
|
103
|
+
Example of provisioning a new t2.micro Ubuntu 16.04 webserver:
|
104
|
+
|
105
|
+
```bash
|
106
|
+
$ knife ec2 server create -r 'role[webserver]' -I ami-5e8bb23b -f t2.micro --aws-access-key-id 'Your AWS Access Key ID' --aws-secret-access-key "Your AWS Secret Access Key" -ssh-key my_key_name --region us-west-2
|
133
107
|
```
|
134
108
|
|
109
|
+
Note: Passing credentials via the command line exposes the credentials in your shell's history and should be avoided unless absolutely necessary.
|
110
|
+
|
111
|
+
## Additional config.rb & knife.rb Configuration Options
|
135
112
|
|
136
|
-
## Additional knife.rb Configuration Options
|
137
113
|
The following configuration options may be set in your `knife.rb`:
|
138
114
|
- flavor
|
139
115
|
- image
|
@@ -141,10 +117,9 @@ The following configuration options may be set in your `knife.rb`:
|
|
141
117
|
- ssh_key_name
|
142
118
|
- aws_session_token
|
143
119
|
- region
|
144
|
-
- distro
|
145
|
-
- template_file
|
146
120
|
|
147
121
|
## Using Cloud-Based Secret Data
|
122
|
+
|
148
123
|
knife-ec2 now includes the ability to retrieve the encrypted data bag secret and validation keys directly from a cloud-based assets store (currently only S3 is supported). To enable this functionality, you must first upload keys to S3 and give them appropriate permissions. The following is a suggested set of IAM permissions required to make this work:
|
149
124
|
|
150
125
|
```json
|
@@ -165,6 +140,7 @@ knife-ec2 now includes the ability to retrieve the encrypted data bag secret and
|
|
165
140
|
```
|
166
141
|
|
167
142
|
### Supported URL format
|
143
|
+
|
168
144
|
- `http` or `https` based: 'http://example.com/chef/my-validator.pem'
|
169
145
|
- `s3` based: 's3://chef/my-validator.pem'
|
170
146
|
|
@@ -176,16 +152,19 @@ knife[:s3_secret] = 'http://example.com/chef/encrypted_data_bag_secret'
|
|
176
152
|
```
|
177
153
|
|
178
154
|
### Alternatively, URLs can be passed directly on the command line:
|
155
|
+
|
179
156
|
- Validation Key: `--validation-key-url s3://chef/my-validator.pem`
|
180
157
|
- Encrypted Data Bag Secret: `--s3-secret s3://chef/encrypted_data_bag_secret`
|
181
158
|
|
182
159
|
## knife-ec2 Subcommands
|
160
|
+
|
183
161
|
This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag
|
184
162
|
|
185
163
|
### `knife ec2 server create`
|
164
|
+
|
186
165
|
Provisions a new server in the Amazon EC2 and then perform a Chef bootstrap (using the SSH or WinRM protocols). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. The examples below create Linux and Windows instances:
|
187
166
|
|
188
|
-
```
|
167
|
+
```bash
|
189
168
|
# Create some instances -- knife configuration contains the AWS credentials
|
190
169
|
|
191
170
|
# A Linux instance via ssh
|
@@ -205,7 +184,7 @@ View additional information on configuring Windows images for bootstrap in the d
|
|
205
184
|
|
206
185
|
#### Adding server_id to the node name
|
207
186
|
|
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.
|
187
|
+
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
188
|
e.g. `-N "www-server-%s" or --chef-node-name "www-server-%s"`
|
210
189
|
|
211
190
|
#### Tagging node in Chef
|
@@ -230,6 +209,7 @@ knife ec2 server create -N chef-node-name -I your-windows-image -f flavor-of-ser
|
|
230
209
|
```
|
231
210
|
|
232
211
|
#### Options for bootstrapping Windows
|
212
|
+
|
233
213
|
The `knife ec2 server create` command also supports the following options for bootstrapping a Windows node after the VM s created:
|
234
214
|
|
235
215
|
```
|
@@ -244,6 +224,7 @@ The `knife ec2 server create` command also supports the following options for bo
|
|
244
224
|
:kerberos_service The Kerberos service used for authentication
|
245
225
|
```
|
246
226
|
### `knife ec2 ami list`
|
227
|
+
|
247
228
|
This command provides the feature to list all EC2 AMIs. It also provides the feature to filter the AMIs based on owner and platform.
|
248
229
|
|
249
230
|
```
|
@@ -251,6 +232,7 @@ knife ec2 ami list
|
|
251
232
|
```
|
252
233
|
|
253
234
|
#### Options for AMIs list
|
235
|
+
|
254
236
|
- **Owner:**
|
255
237
|
By default owner is aws-marketplace but you can specify following owner with the help of -o or --owner:
|
256
238
|
|
@@ -279,20 +261,35 @@ knife ec2 ami list
|
|
279
261
|
```
|
280
262
|
|
281
263
|
### `knife ec2 server list`
|
264
|
+
|
282
265
|
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.**
|
283
266
|
|
284
267
|
### `knife ec2 flavor list`
|
268
|
+
|
285
269
|
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
270
|
|
287
271
|
### `knife ec2 server delete`
|
272
|
+
|
288
273
|
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**
|
289
274
|
|
290
|
-
##
|
291
|
-
- Author:: Adam Jacob ([adam@chef.io](mailto:adam@chef.io))
|
275
|
+
## Development Documentation
|
292
276
|
|
293
|
-
|
294
|
-
|
277
|
+
All documentation is written using YARD. You can generate a by running:
|
278
|
+
|
279
|
+
```
|
280
|
+
rake docs
|
281
|
+
```
|
295
282
|
|
283
|
+
## Contributing
|
284
|
+
|
285
|
+
For information on contributing to this project please see our [Contributing Documentation](https://github.com/chef/chef/blob/master/CONTRIBUTING.md)
|
286
|
+
|
287
|
+
## License & Copyright
|
288
|
+
|
289
|
+
- Copyright:: Copyright (c) 2009-2018 Chef Software, Inc.
|
290
|
+
- License:: Apache License, Version 2.0
|
291
|
+
|
292
|
+
```text
|
296
293
|
Licensed under the Apache License, Version 2.0 (the "License");
|
297
294
|
you may not use this file except in compliance with the License.
|
298
295
|
You may obtain a copy of the License at
|