From d3a4874ab3493e9a590b565a5186e79415d9631c Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 24 May 2016 17:08:01 -0400 Subject: [PATCH] Quiet foodcritic and solve some rubocop stuff --- Rakefile | 2 +- recipes/default.rb | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 1edd34c..a8abd92 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ namespace :style do FoodCritic::Rake::LintTask.new(:chef) do |t| t.options = { fail_tags: ['any'], - tags: [''] + tags: ['~FC022'] } end end diff --git a/recipes/default.rb b/recipes/default.rb index b3c464e..0565907 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -28,7 +28,6 @@ agent_config_info_file = '/opt/threatstack/cloudsight/config/config.json' - package 'threatstack-agent' do version node['threatstack']['version'] if node['threatstack']['version'] action node['threatstack']['pkg_action'] @@ -47,7 +46,7 @@ # and if it's omitted then the agent will be placed into a # default rule set (most like 'Base Rule Set') cmd = '' -if ! agent_config_args.empty? +unless agent_config_args.empty? agent_config_args.each do |arg| cmd += "cloudsight config #{arg} ;" end @@ -57,7 +56,7 @@ cmd += " #{node['threatstack']['agent_extra_args']}" if node['threatstack']['agent_extra_args'] != '' # Handle ruleset management via here. -if ! node['threatstack']['rulesets'].empty? +unless node['threatstack']['rulesets'].empty? node['threatstack']['rulesets'].each do |r| cmd += " --ruleset='#{r}'" @@ -106,13 +105,13 @@ end # This block is for reconfiguring the agent after setup has been completed. - if ! agent_config_args.empty? + unless agent_config_args.empty? require 'json' # We can only set one argument at a time to build a string of `cloudsight # config` commands per argument. cloudsight_config_cmds = [] - if ! node['threatstack']['agent_config_args'].nil? + unless node['threatstack']['agent_config_args'].nil? agent_config_args = node['threatstack']['agent_config_args'].split(' ') agent_config_args.each do |arg| cloudsight_config_cmds.push("cloudsight config #{arg}") @@ -130,13 +129,16 @@ end not_if do args_hash = JSON.parse(File.open(agent_config_info_file).read) + no_changes = true agent_config_args.each do |arg| - k,v = arg.split('=') + k, v = arg.split('=') # If this fails then just break out causing - if !(args_hash.has_key? k and args_hash.fetch(k) == v) + unless (args_hash.key? k) && (args_hash.fetch(k) == v) + no_changes = false break end end + no_changes end notifies :restart, 'service[cloudsight]' end