chef-busboy 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/busboy +6 -0
  3. data/lib/chef-busboy.rb +94 -0
  4. metadata +73 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7884a9199a8dcf57b9b3044aa6811f0617d8300b
4
+ data.tar.gz: 10e96cecc9da5d48c6c80fe61bb1bdd8f2899648
5
+ SHA512:
6
+ metadata.gz: 07ef3d45ee8a623d0c53ef9323d177ccad14436da1c499ad6cd22e228977186958edabb3289b736e0907b98a75761e69c6378fb1c4ed599af4a1d7dc3d760222
7
+ data.tar.gz: 4cf694bdbb20e305184dded9c37b723580eea80c5bc053d91af681967497f25ed9e49d0bb90c5c2c513483fe86ee32f2934d01f402845a391ccab731f926ee89
data/bin/busboy ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'chef-busboy'
4
+
5
+ ChefBusBoy.start(ARGV)
6
+
@@ -0,0 +1,94 @@
1
+ require 'thor'
2
+ require 'ridley'
3
+
4
+ Ridley::Logging.logger.level = Logger.const_get 'FATAL'
5
+
6
+ class ChefBusBoy < Thor
7
+ @@chef_server = ''
8
+
9
+ desc "run_list_add", "Add recipes the run list for all nodes matching a search"
10
+ option :search_string, :required => true
11
+ option :recipe_string, :required => true
12
+ def run_list_add()
13
+ results = search(options[:search_string])
14
+ if results.empty?
15
+ puts "No nodes match this search string"
16
+ else
17
+ print_nodes(results)
18
+ answer = get_user_confirmation("These are the nodes that matched your search and will be updated. Would you like to continue? y/n")
19
+ if answer
20
+ puts "Selections confirmed...updating run lists now..."
21
+ results.each do |node|
22
+ puts "Updating #{node.name}'s run list with #{options[:recipe_string]}"
23
+ node.run_list << "#{options[:recipe_string]}"
24
+ get_connection.node.update(node)
25
+ end
26
+ else
27
+ puts "Transaction cancelled. Not updating any nodes"
28
+ end
29
+ end
30
+ end
31
+
32
+ desc "node_env_change", "Move nodes to new environment"
33
+ option :search_string, :required => true
34
+ option :environment, :required => true
35
+ def node_env_change
36
+ results = search(options[:search_string])
37
+ if results.empty?
38
+ puts "No nodes match this search string"
39
+ else
40
+ print_nodes(results)
41
+ answer = get_user_confirmation("These are the nodes that matched your search and will be updated. Would you like to continue? y/n")
42
+ if answer
43
+ puts "Selections confirmed...updating environments now..."
44
+ results.each do |node|
45
+ puts "Changing #{node.name}'s environment to #{options[:environment]}"
46
+ node.chef_environment = "#{options[:environment]}"
47
+ get_connection.node.update(node)
48
+ end
49
+ else
50
+ puts "Transaction cancelled. Not updating any nodes"
51
+ end
52
+ end
53
+ end
54
+
55
+ desc "node_search", "Search for nodes based on supplied search query"
56
+ option :search_string, :required => true
57
+ def node_search
58
+ results = search(options[:search_string])
59
+ if results.empty?
60
+ puts "No nodes matched this search"
61
+ else
62
+ print_nodes(results)
63
+ puts "#{results.length} nodes found"
64
+ end
65
+ end
66
+
67
+
68
+ no_commands {
69
+ def get_connection
70
+ @@chef_server = Ridley.from_chef_config(nil, {:ssl => {:verify => false}})
71
+ end
72
+
73
+ def search(string)
74
+ chef_server = get_connection
75
+ results = chef_server.partial_search(:node, "#{options[:search_string]}", "", {:rows => 5000})
76
+ end
77
+
78
+ def print_nodes(nodes)
79
+ nodes.each do |node|
80
+ puts "#{node.name}"
81
+ end
82
+ end
83
+
84
+ def get_user_confirmation(prompt)
85
+ answer = ask(prompt).to_s.downcase
86
+ if (answer == "y" || answer == "yes")
87
+ return true
88
+ else
89
+ return false
90
+ end
91
+ end
92
+ }
93
+ end
94
+
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-busboy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nolan Davidson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ridley
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Command line tool for chef-server, implementing a small subset of activities
42
+ email: ndavidson@scrippsnetworks.com
43
+ executables:
44
+ - busboy
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/chef-busboy.rb
49
+ - bin/busboy
50
+ homepage:
51
+ licenses: []
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.0.6
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Command line tool for chef-server
73
+ test_files: []