Commit 99e3a657 authored by Andrew Crump's avatar Andrew Crump

FC003: Check before using server-specific features

parent 237cbb89
......@@ -22,8 +22,11 @@ ossec_server = Array.new
if node.run_list.roles.include?(node['ossec']['server_role'])
ossec_server << node['ipaddress']
else
search(:node,"role:#{node['ossec']['server_role']}") do |n|
ossec_server << n['ipaddress']
if Chef::Config[:solo]
Chef::Log.warn("This recipe uses search. Chef Solo does not support search.")
search(:node,"role:#{node['ossec']['server_role']}") do |n|
ossec_server << n['ipaddress']
end
end
end
......
......@@ -28,14 +28,18 @@ agent_manager = "#{node['ossec']['user']['dir']}/bin/ossec-batch-manager.pl"
ssh_hosts = Array.new
search(:node, "ossec:[* TO *] NOT role:#{node['ossec']['server_role']}") do |n|
if Chef::Config[:solo]
Chef::Log.warn("This recipe uses search. Chef Solo does not support search.")
else
search(:node, "ossec:[* TO *] NOT role:#{node['ossec']['server_role']}") do |n|
ssh_hosts << n['ipaddress'] if n['keys']
ssh_hosts << n['ipaddress'] if n['keys']
execute "#{agent_manager} -a --ip #{n['ipaddress']} -n #{n['hostname']}" do
not_if "grep '#{n['hostname']} #{n['ipaddress']}' #{node['ossec']['user']['dir']}/etc/client.keys"
end
execute "#{agent_manager} -a --ip #{n['ipaddress']} -n #{n['hostname']}" do
not_if "grep '#{n['hostname']} #{n['ipaddress']}' #{node['ossec']['user']['dir']}/etc/client.keys"
end
end
end
template "/usr/local/bin/dist-ossec-keys.sh" do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment