knife-solo 0.3.0.pre2 → 0.3.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +70 -27
- data/README.rdoc +11 -6
- data/Rakefile +4 -2
- data/lib/chef/knife/bootstrap_solo.rb +40 -0
- data/lib/chef/knife/solo_bootstrap.rb +1 -1
- data/lib/chef/knife/solo_clean.rb +16 -4
- data/lib/chef/knife/solo_cook.rb +111 -36
- data/lib/chef/knife/solo_init.rb +14 -0
- data/lib/chef/knife/solo_prepare.rb +1 -1
- data/lib/knife-solo/bootstraps.rb +0 -18
- data/lib/knife-solo/bootstraps/darwin.rb +4 -16
- data/lib/knife-solo/bootstraps/linux.rb +36 -48
- data/lib/knife-solo/info.rb +1 -1
- data/lib/knife-solo/resources/knife.rb +4 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/.travis.yml +7 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/CHANGELOG +16 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/LICENSE +202 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/NOTICE +18 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/README.md +141 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search.rb +72 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/overrides.rb +99 -0
- data/lib/{chef/knife/patches → knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search}/parser.rb +1 -2
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene.treetop +150 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb +285 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb +65 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/metadata.rb +11 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/recipes/default.rb +2 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/Gemfile +8 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/alpha.json +10 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/beta.json +10 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/without_json_class.json +7 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/jerry.json +8 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/lea.json +10 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/mike.json +13 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/tom.json +10 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/test_data_bags.rb +44 -0
- data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/test_search.rb +241 -0
- data/lib/knife-solo/resources/solo.rb.erb +10 -0
- data/lib/knife-solo/ssh_command.rb +4 -3
- data/lib/knife-solo/tools.rb +22 -0
- data/test/bootstraps_test.rb +4 -11
- data/test/integration/cases/encrypted_data_bag.rb +3 -0
- data/test/integration/cases/knife_bootstrap.rb +14 -0
- data/test/integration/debian6_bootstrap_test.rb +1 -1
- data/test/integration/{debian7_bootstrap_test.rb → debian7_knife_bootstrap_test.rb} +3 -3
- data/test/knife_bootstrap_test.rb +61 -0
- data/test/solo_cook_test.rb +78 -3
- data/test/support/integration_test.rb +8 -3
- data/test/tools_test.rb +82 -0
- metadata +63 -21
- data/lib/chef/knife/patches/search.rb +0 -110
- data/lib/knife-solo/config.rb +0 -39
- data/lib/knife-solo/resources/solo.rb +0 -6
- data/test/knife-solo/config_test.rb +0 -38
@@ -0,0 +1,285 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Seth Falcon (<seth@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'treetop'
|
20
|
+
|
21
|
+
module Lucene
|
22
|
+
SEP = "__=__"
|
23
|
+
|
24
|
+
class Term < Treetop::Runtime::SyntaxNode
|
25
|
+
def to_array
|
26
|
+
"T:#{self.text_value}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def transform
|
30
|
+
self.text_value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Field < Treetop::Runtime::SyntaxNode
|
35
|
+
def to_array
|
36
|
+
field = self.elements[0].text_value
|
37
|
+
term = self.elements[1].to_array
|
38
|
+
"(F:#{field} #{term})"
|
39
|
+
end
|
40
|
+
|
41
|
+
def transform
|
42
|
+
field = self.elements[0].text_value
|
43
|
+
term = self.elements[1]
|
44
|
+
if term.is_a? Phrase
|
45
|
+
str = term.transform
|
46
|
+
# remove quotes
|
47
|
+
str = str[1 ... (str.length - 1)]
|
48
|
+
"content:\"#{field}#{SEP}#{str}\""
|
49
|
+
else
|
50
|
+
"content:#{field}#{SEP}#{term.transform}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class FieldRange < Treetop::Runtime::SyntaxNode
|
56
|
+
|
57
|
+
def to_array
|
58
|
+
field = self.elements[0].text_value
|
59
|
+
range_start = self.elements[1].to_array
|
60
|
+
range_end = self.elements[2].to_array
|
61
|
+
"(FR:#{field} #{left}#{range_start}#{right} #{left}#{range_end}#{right})"
|
62
|
+
end
|
63
|
+
|
64
|
+
def transform
|
65
|
+
field = self.elements[0].text_value
|
66
|
+
range_start = self.elements[1].transform
|
67
|
+
range_end = self.elements[2].transform
|
68
|
+
# FIXME: handle special cases for missing start/end
|
69
|
+
if ("*" == range_start && "*" == range_end)
|
70
|
+
"content:#{field}#{SEP}*"
|
71
|
+
elsif "*" == range_end
|
72
|
+
"content:#{left}#{field}#{SEP}#{range_start} TO #{field}#{SEP}\\ufff0#{right}"
|
73
|
+
elsif "*" == range_start
|
74
|
+
"content:#{left}#{field}#{SEP} TO #{field}#{SEP}#{range_end}#{right}"
|
75
|
+
else
|
76
|
+
"content:#{left}#{field}#{SEP}#{range_start} TO #{field}#{SEP}#{range_end}#{right}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
class InclFieldRange < FieldRange
|
83
|
+
def left
|
84
|
+
"["
|
85
|
+
end
|
86
|
+
def right
|
87
|
+
"]"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class ExclFieldRange < FieldRange
|
92
|
+
def left
|
93
|
+
"{"
|
94
|
+
end
|
95
|
+
def right
|
96
|
+
"}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class RangeValue < Treetop::Runtime::SyntaxNode
|
101
|
+
def to_array
|
102
|
+
self.text_value
|
103
|
+
end
|
104
|
+
|
105
|
+
def transform
|
106
|
+
to_array
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class FieldName < Treetop::Runtime::SyntaxNode
|
111
|
+
def to_array
|
112
|
+
self.text_value
|
113
|
+
end
|
114
|
+
|
115
|
+
def transform
|
116
|
+
to_array
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
class Body < Treetop::Runtime::SyntaxNode
|
122
|
+
def to_array
|
123
|
+
self.elements.map { |x| x.to_array }.join(" ")
|
124
|
+
end
|
125
|
+
|
126
|
+
def transform
|
127
|
+
self.elements.map { |x| x.transform }.join(" ")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Group < Treetop::Runtime::SyntaxNode
|
132
|
+
def to_array
|
133
|
+
"(" + self.elements[0].to_array + ")"
|
134
|
+
end
|
135
|
+
|
136
|
+
def transform
|
137
|
+
"(" + self.elements[0].transform + ")"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
class BinaryOp < Treetop::Runtime::SyntaxNode
|
142
|
+
def to_array
|
143
|
+
op = self.elements[1].to_array
|
144
|
+
a = self.elements[0].to_array
|
145
|
+
b = self.elements[2].to_array
|
146
|
+
"(#{op} #{a} #{b})"
|
147
|
+
end
|
148
|
+
|
149
|
+
def transform
|
150
|
+
op = self.elements[1].transform
|
151
|
+
a = self.elements[0].transform
|
152
|
+
b = self.elements[2].transform
|
153
|
+
"#{a} #{op} #{b}"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
class AndOperator < Treetop::Runtime::SyntaxNode
|
158
|
+
def to_array
|
159
|
+
"OP:AND"
|
160
|
+
end
|
161
|
+
|
162
|
+
def transform
|
163
|
+
"AND"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
class OrOperator < Treetop::Runtime::SyntaxNode
|
168
|
+
def to_array
|
169
|
+
"OP:OR"
|
170
|
+
end
|
171
|
+
|
172
|
+
def transform
|
173
|
+
"OR"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
class FuzzyOp < Treetop::Runtime::SyntaxNode
|
178
|
+
def to_array
|
179
|
+
a = self.elements[0].to_array
|
180
|
+
param = self.elements[1]
|
181
|
+
if param
|
182
|
+
"(OP:~ #{a} #{param.to_array})"
|
183
|
+
else
|
184
|
+
"(OP:~ #{a})"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def transform
|
189
|
+
a = self.elements[0].transform
|
190
|
+
param = self.elements[1]
|
191
|
+
if param
|
192
|
+
"#{a}~#{param.transform}"
|
193
|
+
else
|
194
|
+
"#{a}~"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
class BoostOp < Treetop::Runtime::SyntaxNode
|
200
|
+
def to_array
|
201
|
+
a = self.elements[0].to_array
|
202
|
+
param = self.elements[1]
|
203
|
+
"(OP:^ #{a} #{param.to_array})"
|
204
|
+
end
|
205
|
+
|
206
|
+
def transform
|
207
|
+
a = self.elements[0].transform
|
208
|
+
param = self.elements[1]
|
209
|
+
"#{a}^#{param.transform}"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
class FuzzyParam < Treetop::Runtime::SyntaxNode
|
214
|
+
def to_array
|
215
|
+
self.text_value
|
216
|
+
end
|
217
|
+
|
218
|
+
def transform
|
219
|
+
self.text_value
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
class UnaryOp < Treetop::Runtime::SyntaxNode
|
224
|
+
def to_array
|
225
|
+
op = self.elements[0].to_array
|
226
|
+
a = self.elements[1].to_array
|
227
|
+
"(#{op} #{a})"
|
228
|
+
end
|
229
|
+
|
230
|
+
def transform
|
231
|
+
op = self.elements[0].transform
|
232
|
+
a = self.elements[1].transform
|
233
|
+
spc = case op
|
234
|
+
when "+", "-"
|
235
|
+
""
|
236
|
+
else
|
237
|
+
" "
|
238
|
+
end
|
239
|
+
"#{op}#{spc}#{a}"
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
class NotOperator < Treetop::Runtime::SyntaxNode
|
245
|
+
def to_array
|
246
|
+
"OP:NOT"
|
247
|
+
end
|
248
|
+
|
249
|
+
def transform
|
250
|
+
"NOT"
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
class RequiredOperator < Treetop::Runtime::SyntaxNode
|
256
|
+
def to_array
|
257
|
+
"OP:+"
|
258
|
+
end
|
259
|
+
|
260
|
+
def transform
|
261
|
+
"+"
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
class ProhibitedOperator < Treetop::Runtime::SyntaxNode
|
267
|
+
def to_array
|
268
|
+
"OP:-"
|
269
|
+
end
|
270
|
+
|
271
|
+
def transform
|
272
|
+
"-"
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
class Phrase < Treetop::Runtime::SyntaxNode
|
277
|
+
def to_array
|
278
|
+
"STR:#{self.text_value}"
|
279
|
+
end
|
280
|
+
|
281
|
+
def transform
|
282
|
+
"#{self.text_value}"
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Seth Falcon (<seth@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
require 'treetop'
|
19
|
+
require 'chef/solr_query/lucene_nodes'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Exceptions
|
23
|
+
class QueryParseError < StandardError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Chef
|
29
|
+
class SolrQuery
|
30
|
+
class QueryTransform
|
31
|
+
@@base_path = File.expand_path(File.dirname(__FILE__))
|
32
|
+
Treetop.load(File.join(@@base_path, 'lucene.treetop'))
|
33
|
+
@@parser = LuceneParser.new
|
34
|
+
|
35
|
+
def self.parse(data)
|
36
|
+
tree = @@parser.parse(data)
|
37
|
+
msg = "Parse error at offset: #{@@parser.index}\n"
|
38
|
+
msg += "Reason: #{@@parser.failure_reason}"
|
39
|
+
raise Chef::Exceptions::QueryParseError, msg if tree.nil?
|
40
|
+
self.clean_tree(tree)
|
41
|
+
tree.to_array
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.transform(data)
|
45
|
+
return "*:*" if data == "*:*"
|
46
|
+
tree = @@parser.parse(data)
|
47
|
+
msg = "Parse error at offset: #{@@parser.index}\n"
|
48
|
+
msg += "Reason: #{@@parser.failure_reason}"
|
49
|
+
raise Chef::Exceptions::QueryParseError, msg if tree.nil?
|
50
|
+
self.clean_tree(tree)
|
51
|
+
tree.transform
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def self.clean_tree(root_node)
|
57
|
+
return if root_node.elements.nil?
|
58
|
+
root_node.elements.delete_if do |node|
|
59
|
+
node.class.name == "Treetop::Runtime::SyntaxNode"
|
60
|
+
end
|
61
|
+
root_node.elements.each { |node| self.clean_tree(node) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
name "chef-solo-search"
|
2
|
+
maintainer "edelight GmbH"
|
3
|
+
maintainer_email "markus.korn@edelight.de"
|
4
|
+
license "Apache 2.0"
|
5
|
+
description "Data bag search for Chef Solo"
|
6
|
+
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
7
|
+
version "0.4.0"
|
8
|
+
|
9
|
+
%w{ ubuntu debian redhat centos fedora freebsd}.each do |os|
|
10
|
+
supports os
|
11
|
+
end
|