buckknife 0.0.5 → 0.0.6

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.
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.6 (2011-07-26)
2
+
3
+ * Add `knife project assign PROJECT [NODE] command.`
4
+
1
5
  ## 0.0.4 (2011-07-22)
2
6
 
3
7
  * Add `knife project new PROJECT` command.
data/README.md CHANGED
@@ -16,6 +16,7 @@ Add these configurations to your `.chef/knife.rb`:
16
16
 
17
17
  ``` ruby
18
18
  knife[:project_dir] = "path/to/chef-rep/data_bags/projects"
19
+ knife[:buckknife_namespace] = "buckknife" # This is a default, you probably don't need to change this
19
20
  ```
20
21
 
21
22
  Here is a complete `~/.chef/knife.rb` example:
@@ -41,4 +41,9 @@ module BuckKnife
41
41
  def self.template_root
42
42
  Pathname.new( File.expand_path("../buckknife/templates", __FILE__) )
43
43
  end
44
+
45
+ def self.namespace
46
+ Chef::Config[:knife][:buckknife_namespace] || "buckknife"
47
+ end
48
+
44
49
  end
@@ -1,3 +1,3 @@
1
1
  module BuckKnife
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,32 @@
1
+ require 'chef/knife'
2
+
3
+ module BuckKnife
4
+ class ProjectAssign < Chef::Knife
5
+ banner "knife project assign PROJECT [NODE]"
6
+
7
+ deps do
8
+ require 'buckknife'
9
+ include BuckKnife::KnifeHelper
10
+ end
11
+
12
+ def run
13
+ project = project_from_arg_or_ask
14
+ node_name = @name_args[1]
15
+ nodes = Array(project.node(node_name) || project.nodes)
16
+
17
+ nodes.each do |node|
18
+ ui.output "# Run this command to assign project attributes to #{node.name}:"
19
+
20
+ code_block = <<-EOF.gsub("\n", "; ")
21
+ node = nodes.search(:name => "#{node.name}").first
22
+ node.set[:#{BuckKnife.namespace}][:project] = "#{project.name}"
23
+ node.set[:#{BuckKnife.namespace}][:environment] = "#{node.environment}"
24
+ node.save
25
+ EOF
26
+
27
+ ui.output BuckKnife::Command.new("knife").arg("exec").opt("-E", code_block )
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -33,7 +33,6 @@ module BuckKnife
33
33
  project.provider = config[:provider] if config[:provider]
34
34
  project.ssh_username = config[:ssh_username] if config[:ssh_username]
35
35
 
36
- # TODO: Move this into project, ActiveModel validation?
37
36
  unless project.valid?
38
37
  ui.fatal("The #{project.name}.json file has some errors that need to be fixed:")
39
38
  project.errors.each do |att, err|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buckknife
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Marini
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-25 00:00:00 -07:00
19
+ date: 2011-07-26 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -176,6 +176,7 @@ files:
176
176
  - lib/buckknife/templates/project.json.erb
177
177
  - lib/buckknife/version.rb
178
178
  - lib/chef/knife/project_add_role.rb
179
+ - lib/chef/knife/project_assign.rb
179
180
  - lib/chef/knife/project_bootstrap.rb
180
181
  - lib/chef/knife/project_capistrano.rb
181
182
  - lib/chef/knife/project_create.rb