knife-whisk 1.0.0 → 2.0.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.
@@ -14,6 +14,7 @@ Assume you've got knife-whisk installed and configured correctly and it's pointi
14
14
  ```
15
15
  mixins:
16
16
  defaults:
17
+ provider: aws
17
18
  image: ami-950680fc # ubuntu instance store
18
19
  subnet: subnet-12345678 # private subnet
19
20
  region: us-east-1
@@ -27,15 +28,21 @@ mixins:
27
28
  public_subnet:
28
29
  subnet: subnet-87654321
29
30
 
30
- security-groups:
31
- default: sg-12345678
32
- java_app_server: sg-34567890
33
-
31
+ provider_config:
32
+ aws:
33
+ cli_command: "ec2 sever create"
34
+ security-groups:
35
+ default: sg-12345678
36
+ java_app_server: sg-34567890
37
+ kvm:
38
+ cli_command: "vm create"
39
+
34
40
  servers:
35
41
  app_server:
36
42
  mixins:
37
43
  - defaults
38
44
  config:
45
+ provider: aws
39
46
  run-list:
40
47
  - "recipe[application-wrapper]"
41
48
  security-groups:
@@ -71,6 +78,8 @@ This is where knife-whisk shines. You don't have to be aware of all the ins and
71
78
 
72
79
  Most importantly, as a team you define what your production servers look like in your whisk.yml file and you'll never bring up a new node with a missing security group because you forgot some ancillary service was on the node that needed it.
73
80
 
81
+ Security groups with VPC are a pain so we added a way to call them by name in your whisk.yml. knife-whisk will translate the `--security-groups name1,name2` to `--security-groups-ids id1,id2` according to what is in your "security-groups" lookup section.
82
+
74
83
  ## Installation
75
84
 
76
85
  Add this line to your application's Gemfile:
@@ -131,7 +140,7 @@ knife whisk generate application_server --mixins public_subnet
131
140
  ```
132
141
 
133
142
  ```
134
- knife whisk generate application_server --overrides "--environment=dev --node-name dev-application-server"
143
+ knife whisk generate application_server --overrides "--environment dev --node-name dev-application-server"
135
144
  ```
136
145
 
137
146
  ## Tab Completion
@@ -140,9 +149,10 @@ knife whisk generate application_server --overrides "--environment=dev --node-na
140
149
  This repository also includes a zsh folder, with a replacement for oh-my-zsh's knife plugin. Copy that to your ~/.oh-my-zsh/plugins/knife folder, and enabled the plugin by adding "knife" to your plugins=() in your .zshrc. You will likely need to reload your shell.
141
150
 
142
151
  ## Todo
143
- * Support for non ec2 setups
152
+ * supprot for --json-attributes knife flag
144
153
  * whisk add mixin
145
154
  * whisk add server
155
+ * whisk provider list
146
156
  * bash tab completion
147
157
 
148
158
  ##Authors
@@ -1,5 +1,6 @@
1
1
  mixins:
2
2
  defaults:
3
+ provider: aws
3
4
  image: ami-950680fc # ubuntu instance store
4
5
  subnet: subnet-12345678 # private subnet
5
6
  region: us-east-1
@@ -8,22 +9,32 @@ mixins:
8
9
  ssh-user: ubuntu
9
10
  template: chef_full
10
11
  security-groups: default
12
+ aws:
13
+ provider: aws
11
14
  ebs:
12
15
  image: ami-e50e888c
13
16
  public_subnet:
14
17
  subnet: subnet-87654321
15
18
 
16
- security-groups:
17
- default: sg-12345678
18
- load_balancer: sg-23456789
19
- java_app_server: sg-34567890
20
- database_server: sg-45678901
19
+ provider_config:
20
+ aws:
21
+ cli_command: "ec2 server create"
22
+ security-groups:
23
+ default: sg-12345678
24
+ load_balancer: sg-23456789
25
+ java_app_server: sg-34567890
26
+ database_server: sg-45678901
27
+ kvm:
28
+ cli_command: "vm create"
29
+ rackspace:
30
+ cli_command: "rackspace server create"
21
31
 
22
32
  servers:
23
33
  prod_nginx_load_balancer:
24
34
  mixins:
25
35
  - defaults
26
36
  - public_subnet
37
+ - aws
27
38
  config:
28
39
  run-list:
29
40
  - "recipe[nginx]"
@@ -48,6 +59,7 @@ servers:
48
59
  - defaults
49
60
  - ebs
50
61
  config:
62
+ provider: rackspace
51
63
  run-list:
52
64
  - "recipe[postgres]"
53
65
  environment: prod
@@ -52,11 +52,11 @@ class Chef
52
52
  end
53
53
 
54
54
  def get_security_groups(groups)
55
- groups.split(',').map! { |name| name.replace(get_config["security-groups"][name]) }.join(',')
55
+ groups.split(',').map! { |name| name.replace(get_config["provider_config"]["aws"]["security-groups"][name]) }.join(',')
56
56
  end
57
57
 
58
58
  def security_group_exists?(group)
59
- ! get_config["security-groups"][group].nil?
59
+ ! get_config["provider_config"]["aws"]["security-groups"][group].nil?
60
60
  end
61
61
 
62
62
  def mixin_exists?(mixin)
@@ -173,18 +173,29 @@ class Chef
173
173
  output_hash = output_hash.merge(@config[:overrides])
174
174
  end
175
175
 
176
- #convert security-group names to ids if needed and make sure they exist in the lookup hash
177
- unless output_hash["security-groups"].nil?
178
- exit_with_message("security-groups not defined in whisk.yml") unless get_config["security-groups"]
179
- output_hash["security-groups"].split(',').each { |group| exit_with_message("#{group} security group does not exist in whisk.yml") unless security_group_exists?(group)}
180
- output_hash["security-group-ids"] = get_security_groups(output_hash["security-groups"])
181
- output_hash.delete("security-groups")
176
+ #check things for aws
177
+ if output_hash["provider"]["aws"]
178
+ #convert security-group names to ids if needed and make sure they exist in the lookup hash
179
+ unless output_hash["security-groups"].nil?
180
+ exit_with_message("security-groups not defined for this config in whisk.yml") unless get_config["provider_config"]["aws"]["security-groups"]
181
+ output_hash["security-groups"].split(',').each { |group| exit_with_message("#{group} security group does not exist in whisk.yml") unless security_group_exists?(group)}
182
+ output_hash["security-group-ids"] = get_security_groups(output_hash["security-groups"])
183
+ output_hash.delete("security-groups")
184
+ end
182
185
  end
183
186
 
184
- # run-list needs quotes for knife ec2 to accept the arg
187
+ #some values need quotes for knife ec2 to accept the arg
185
188
  output_hash["run-list"] = add_quotes(output_hash["run-list"]) unless output_hash["run-list"].nil?
189
+ # json doesn't work currently output_hash["json-attributes"] = add_quotes(output_hash["json-attributes"]) unless output_hash["json-attributes"].nil?
190
+
191
+ #get config string and check to make sure it exists
192
+ exit_with_message("provider attribute must be provided") unless output_hash["provider"]
193
+ exit_with_message("#{output_hash["provider"]} cli_command doesn't exist in whisk.yml") unless full_hash["provider_config"][output_hash["provider"]]["cli_command"]
194
+ cli_command = full_hash["provider_config"][output_hash["provider"]]["cli_command"]
195
+
196
+ output_hash.delete("provider")
186
197
 
187
- printf "knife ec2 server create %s\n", output_hash.map { |key, value| ["--"+key, value] }.join(" ")
198
+ printf "knife %s %s\n", cli_command, output_hash.map { |key, value| ["--"+key, value] }.join(" ")
188
199
  end
189
200
  end
190
201
  end
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Whisk
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,27 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-whisk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Nic Grayson
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-03-12 00:00:00.000000000 Z
12
+ date: 2013-03-22 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: chef
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  description: A utility for quickly whipping up new servers in a team environment
@@ -45,25 +48,26 @@ files:
45
48
  - zsh/_knife
46
49
  homepage: ''
47
50
  licenses: []
48
- metadata: {}
49
51
  post_install_message:
50
52
  rdoc_options: []
51
53
  require_paths:
52
54
  - lib
53
55
  required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
54
57
  requirements:
55
- - - '>='
58
+ - - ! '>='
56
59
  - !ruby/object:Gem::Version
57
60
  version: '0'
58
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
59
63
  requirements:
60
- - - '>='
64
+ - - ! '>='
61
65
  - !ruby/object:Gem::Version
62
66
  version: '0'
63
67
  requirements: []
64
68
  rubyforge_project:
65
- rubygems_version: 2.0.0
69
+ rubygems_version: 1.8.23
66
70
  signing_key:
67
- specification_version: 4
71
+ specification_version: 3
68
72
  summary: Extends knife to display knife ec2 server create commands
69
73
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 14bd4c3ad621d14ee341d773ff75ad7afa5dacf1
4
- data.tar.gz: b028449ba2113dc75b28262ebfec758692db58f7
5
- SHA512:
6
- metadata.gz: 19dc6286ebf16222c7d5682f9b795492f29d3a677c987fa562bb66a00d98482e92ff31ca27e5c1b554a06e3ffac85d5b3709dfc11f297dfc8f1078693327c623
7
- data.tar.gz: 3ad95946d5165a3926a8a0bdf0510e54005035142b68d2ef80a3d771a16331a3a848ff8273735d9a4394e9141d8af204bcc26350814ed8a73b399507a8e6cfc4