Fixed foodcritic issues, added proper cookbook includes per platform

This commit is contained in:
Eric Renfro 2016-07-24 16:27:10 -04:00
parent 03cb22c10f
commit 6b18d206ed
4 changed files with 96 additions and 88 deletions

View File

@ -4,7 +4,7 @@ maintainer_email "psi-jack@linux-help.org"
license "GPLv2"
description "Installs/Configures ossec"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.2.0"
version "1.2.1"
issues_url "http://git.linux-help.org/Linux-Help/ossec-ng/issues"
source_url "http://git.linux-help.org/Linux-Help/ossec-ng"
@ -26,7 +26,7 @@ end
depends 'yum-epel'
depends 'yum-atomic', '~> 0.1.2'
depends 'apt-atomic', '~> 0.1.2'
depends 'apt-atomic', '~> 0.1.3'
suggests 'postfix'
suggests 'selinux_policy'

View File

@ -3,11 +3,11 @@
# and role specific configuration for the node
# get a key from the ossec-server if there's one
#if not node['lsb']['codename'].eql?('lucid')
# return true
#end
if node['platform_family'] == "rhel"
include_recipe "yum-atomic"
elsif node['platform_family'] == "debian"
include_recipe "apt-atomic"
end
class Chef::Recipe
include OssecCore
@ -25,6 +25,9 @@ if not node["ossec"]["agent"]["enable"]
end
# Search for the ossec server, and do nothing if there's none
if Chef::Config[:solo]
Chef::Log.warn('This recipe uses search. Chef Solo does not support search')
else
ossec_server = search(:node,
"role:ossec-server " \
"AND chef_environment:#{node.chef_environment}"
@ -104,13 +107,13 @@ ruby_block "set-rid-flag" do
end
# unset rid flag if necessary, check that at every run
if node["ossec"]["agents"][agent_hash[:id]]["rid"].eql?("todo") \
and ossec_server["ossec"]["agents"][agent_hash[:id]]["rid"].eql?("done")
ruby_block "unset rid flag" do
block do
node.normal["ossec"]["agents"][agent_hash[:id]]["rid"] = "none"
Chef::Log.info "Setting Queue Rid Flag off"
end
notifies :restart, "service[ossec-agent]"
only_if { node["ossec"]["agents"][agent_hash[:id]]["rid"].eql?("todo") \
and ossec_server["ossec"]["agents"][agent_hash[:id]]["rid"].eql?("done") }
end
end

View File

@ -2,5 +2,5 @@
# Cookbook Name:: ossec
# Recipe:: default
#
include_recipe "ossec::agent"
include_recipe "ossec-ng::agent"

View File

@ -2,7 +2,12 @@
# install the ossec-hids-server package and push the
# default configuration from the templates
if node['platform_family'] == "rhel"
include_recipe "yum-atomic"
elsif node['platform_family'] == "debian"
include_recipe "apt-atomic"
end
class Chef::Recipe
include OssecCore