Skip to content

Commit

Permalink
Merge pull request #25 from jeremymv2/fail_if_audits_fail
Browse files Browse the repository at this point in the history
failing converge if any audits failed
  • Loading branch information
chris-rock committed Apr 18, 2016
2 parents c347d6b + 2632a61 commit 99f5f53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions attributes/default.rb
Expand Up @@ -24,3 +24,6 @@

# fail converge if downloaded profile is not present
default['audit']['fail_if_not_present'] = false

# fail converge after posting report if any audits have failed
default['audit']['fail_if_any_audits_failed'] = false
3 changes: 3 additions & 0 deletions libraries/report.rb
Expand Up @@ -26,6 +26,8 @@ class ComplianceReport < Chef::Resource

blob = node_info
blob[:reports] = reports
total_failed = 0
blob[:reports].each { |k, _| total_failed += blob[:reports][k]['summary']['failure_count'].to_i }
blob[:profiles] = ownermap

Chef::Config[:verify_api_cert] = false
Expand All @@ -46,6 +48,7 @@ class ComplianceReport < Chef::Resource
Chef::Log.error 'Report NOT saved to server.'
raise e if run_context.node.audit.raise_if_unreachable
end
fail "#{total_failed} audits have failed. Aborting chef-client run." if total_failed > 0 && run_context.node.audit.fail_if_any_audits_failed
end
end

Expand Down

0 comments on commit 99f5f53

Please sign in to comment.