knife-preflight 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +13 -0
  2. data/lib/chef/knife/preflight.rb +23 -7
  3. metadata +3 -3
data/README.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  A preflight plugin for Chef::Knife which lets you see which nodes and roles use a particular cookbook before you upload it.
4
4
 
5
+ # Installation
6
+
7
+ ## SCRIPT INSTALL
8
+
9
+ Copy preflight.rb script from lib/chef/knife to your ~/.chef/plugins/knife directory.
10
+
11
+ ## GEM INSTALL
12
+ knife-prelight is available on rubygems.org - if you have that source in your gemrc, you can simply use:
13
+
14
+ ````
15
+ gem install knife-preflight
16
+ ````
17
+
5
18
  ## Preface
6
19
 
7
20
  Searches the expanded run_lists of all nodes along with the run_list of all roles for the specified cookbook
@@ -60,17 +60,24 @@ module KnifePreflight
60
60
 
61
61
  q_nodes = Chef::Search::Query.new
62
62
 
63
-
64
63
  escaped_query = raw_query.sub( "::", "\\:\\:")
65
- node_query = "recipes:*#{escaped_query}"
64
+
65
+ if !raw_query.include? "::"
66
+ node_query = "recipes:*#{escaped_query} OR recipes:*#{escaped_query}\\:\\:default"
67
+ ui.msg("Searching for nodes containing #{raw_query} OR #{raw_query}::default in their expanded run_list...\n")
68
+ elsif raw_query.include? "::default"
69
+ node_query = "recipes:*#{escaped_query} OR recipes:*#{escaped_query.gsub( "\\:\\:default","")}"
70
+ ui.msg("Searching for nodes containing #{raw_query} OR #{raw_query.gsub( "::default","")} in their expanded run_list...\n")
71
+ else
72
+ node_query = "recipes:*#{escaped_query}"
73
+ ui.msg("Searching for nodes containing #{raw_query} in their expanded run_list...\n")
74
+ end
66
75
  query_nodes = URI.escape(node_query,
67
76
  Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
68
77
 
69
78
  result_items_nodes = []
70
79
  result_count_nodes = 0
71
80
 
72
- ui.msg("Searching for nodes containing #{raw_query} in their expanded run_list...\n")
73
-
74
81
  rows = config[:rows]
75
82
  start = config[:start]
76
83
  begin
@@ -103,15 +110,24 @@ module KnifePreflight
103
110
 
104
111
 
105
112
  q_roles = Chef::Search::Query.new
106
- role_query = "run_list:recipe\\[#{escaped_query}\\]"
113
+
114
+ if !raw_query.include? "::"
115
+ role_query = "run_list:recipe\\[#{escaped_query}\\] OR run_list:recipe\\[#{escaped_query}\\:\\:default\\]"
116
+ ui.msg("Searching for roles containing #{raw_query} OR #{raw_query}::default in their expanded run_list...\n")
117
+ elsif raw_query.include? "::default"
118
+ role_query = "run_list:recipe\\[#{escaped_query}\\] OR run_list:recipe\\[#{escaped_query.gsub( "\\:\\:default","")}\\]"
119
+ ui.msg("Searching for roles containing #{raw_query} OR #{raw_query.gsub( "::default","")} in their expanded run_list...\n")
120
+ else
121
+ role_query = "run_list:recipe\\[#{escaped_query}\\]"
122
+ ui.msg("Searching for roles containing #{raw_query} in their expanded run_list...\n")
123
+ end
124
+
107
125
  query_roles = URI.escape(role_query,
108
126
  Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
109
127
 
110
128
  result_items_roles = []
111
129
  result_count_roles = 0
112
130
 
113
- ui.msg("Searching for roles containing #{raw_query} in their run_list...\n")
114
-
115
131
  rows = config[:rows]
116
132
  start = config[:start]
117
133
  begin
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jon Cowie
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-01-31 00:00:00 +00:00
17
+ date: 2012-02-02 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency