edelight / chef-solo-search

Data bag search for Chef Solo
Apache License 2.0
177 stars 2 forks source link

Treetop not loaded with chef-solo and --why-run #49

Closed crawley closed 10 years ago

crawley commented 10 years ago

When I try to run a recipe that depends on chef-solo-search on an omnibus Chef 11.8.0 install using "chef-solo ... -W", I get the following error. When I remove the "-W", it works.

Starting Chef Client, version 11.8.0
Compiling Cookbooks...

================================================================================
Recipe Compile Error in /var/chef-solo/cvl-chef/cookbooks/chef-solo-search/libraries/search.rb
================================================================================

LoadError
---------
cannot load such file -- treetop

Cookbook Trace:
---------------
  /var/chef-solo/cvl-chef/cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb:18:in `<top (required)>'
  /var/chef-solo/cvl-chef/cookbooks/chef-solo-search/libraries/search/parser.rb:20:in `<top (required)>'
  /var/chef-solo/cvl-chef/cookbooks/chef-solo-search/libraries/search.rb:41:in `<top (required)>'

Relevant File Content:
----------------------
/var/chef-solo/cvl-chef/cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb:

 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:  
michaelglass commented 10 years ago

this is by design in chef https://tickets.opscode.com/browse/CHEF-3319

If you can find the docs for how to detect chef whyrun mode, I'll throw in the code to give a more friendly error message.

If you want to run in why mode anyways, ensure that treetop is installed into chef's embedded ruby parts before you run chef-solo. (ssh into your server and /opt/chef/embedded/bin/gem install treetop I think)

crawley commented 10 years ago

I think you should just be able to check the config hash; i.e.

Chef::Config[:solo]

is set to true when chef-solo starts. Mobile: 0427 027 304

crawley commented 10 years ago

Sorry ... not enough coffee.

Try Chef::Config[:why_run]

michaelglass commented 10 years ago

beautiful. thanks, @crawley

michaelglass commented 10 years ago

@crawley mind testing my branch, (#50)