Skip to content

Commit

Permalink
[COOK-2479] Permit users cookbook to work with chef-solo if edelight/…
Browse files Browse the repository at this point in the history
…chef-solo-search is installed.
  • Loading branch information
brandonmartin committed Feb 25, 2013
1 parent c51c96a commit dd4f4e5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions providers/manage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ def initialize(*args)
@action = :create
end

def chef_solo_search_installed?
klass = ::Search::const_get('Helper')
return klass.is_a?(Class)
rescue NameError
return false
end

action :remove do
if Chef::Config[:solo]
Chef::Log.warn("This recipe uses search. Chef Solo does not support search.")
if Chef::Config[:solo] and not chef_solo_search_installed?
Chef::Log.warn("This recipe uses search. Chef Solo does not support search unless you install the chef-solo-search cookbook.")
else
search(new_resource.data_bag, "groups:#{new_resource.search_group} AND action:remove") do |rm_user|
user rm_user['username'] ||= rm_user['id'] do
Expand All @@ -43,8 +50,8 @@ def initialize(*args)
action :create do
security_group = Array.new

if Chef::Config[:solo]
Chef::Log.warn("This recipe uses search. Chef Solo does not support search.")
if Chef::Config[:solo] and not chef_solo_search_installed?
Chef::Log.warn("This recipe uses search. Chef Solo does not support search unless you install the chef-solo-search cookbook.")
else
search(new_resource.data_bag, "groups:#{new_resource.search_group} AND NOT action:remove") do |u|
u['username'] ||= u['id']
Expand Down

0 comments on commit dd4f4e5

Please sign in to comment.