summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kitchen-tests/cookbooks/webapp/README.md8
-rw-r--r--lib/chef/application/client.rb10
-rw-r--r--lib/chef/application/solo.rb4
-rw-r--r--lib/chef/audit/audit_reporter.rb3
-rw-r--r--lib/chef/client.rb8
-rw-r--r--lib/chef/config.rb4
-rw-r--r--spec/functional/resource/deploy_revision_spec.rb2
-rw-r--r--spec/functional/resource/git_spec.rb2
8 files changed, 26 insertions, 15 deletions
diff --git a/kitchen-tests/cookbooks/webapp/README.md b/kitchen-tests/cookbooks/webapp/README.md
index e8de6ee467..5c55542cbf 100644
--- a/kitchen-tests/cookbooks/webapp/README.md
+++ b/kitchen-tests/cookbooks/webapp/README.md
@@ -1,4 +1,10 @@
# webapp
-TODO: Enter the cookbook description here.
+This cookbook has some basic recipes to test audit mode.
+In order to run these tests on your dev box:
+
+```
+$ bundle install
+$ bundle exec chef-client -c kitchen-tests/.chef/client.rb -z -o audit_test::default
+```
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 295dc2470e..b10f818cf4 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -241,7 +241,15 @@ class Chef::Application::Client < Chef::Application
option :audit_mode,
:long => "--[no-]audit-mode",
:description => "If not specified, run converge and audit phase. If true, run only audit phase. If false, run only converge phase.",
- :boolean => true
+ :boolean => true,
+ :proc => lambda { |set|
+ # Convert boolean to config options of :audit_only or :disabled
+ if set
+ :audit_only
+ else
+ :disabled
+ end
+ }
IMMEDIATE_RUN_SIGNAL = "1".freeze
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 50f7f5c5d4..c3f5444ef7 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -212,8 +212,8 @@ class Chef::Application::Solo < Chef::Application
@chef_client_json = config_fetcher.fetch_json
end
- # If we don't specify this, solo will try to perform the audits
- Chef::Config[:audit_mode] = false
+ # Disable auditing for solo
+ Chef::Config[:audit_mode] = :disabled
end
def setup_application
diff --git a/lib/chef/audit/audit_reporter.rb b/lib/chef/audit/audit_reporter.rb
index af94f0968b..ce4978180e 100644
--- a/lib/chef/audit/audit_reporter.rb
+++ b/lib/chef/audit/audit_reporter.rb
@@ -31,7 +31,6 @@ class Chef
PROTOCOL_VERSION = '0.1.0'
def initialize(rest_client)
- @audit_enabled = Chef::Config[:audit_mode]
@rest_client = rest_client
# Ruby 1.9.3 and above "enumerate their values in the order that the corresponding keys were inserted."
@ordered_control_groups = Hash.new
@@ -87,7 +86,7 @@ class Chef
# If @audit_enabled is nil or true, we want to run audits
def auditing_enabled?
- @audit_enabled != false
+ Chef::Config[:audit_mode] != :disabled
end
private
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 9e1d2dc207..aa0d6722fe 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -441,16 +441,12 @@ class Chef
run_context = setup_run_context
- unless Chef::Config[:audit_mode] == true
+ if Chef::Config[:audit_mode] != :audit_only
converge_error = converge_and_save(run_context)
- else
- Chef::Log.debug("Skipping converge. Chef is configured to run audits only.")
end
- unless Chef::Config[:audit_mode] == false
+ if Chef::Config[:audit_mode] != :disabled
audit_error = run_audits(run_context)
- else
- Chef::Log.debug("Skipping audits. Chef is configured to converge the node only.")
end
if converge_error || audit_error
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index 7613a4fd4a..19fa272100 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -319,7 +319,9 @@ class Chef
default :client_fork, true
default :enable_reporting, true
default :enable_reporting_url_fatals, false
- default :audit_mode, nil
+ # Possible values for :audit_mode
+ # :enabled, :disabled, :audit_only,
+ default :audit_mode, :enabled
# Policyfile is an experimental feature where a node gets its run list and
# cookbook version set from a single document on the server instead of
diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb
index 7bc3da9a05..05a21c48c7 100644
--- a/spec/functional/resource/deploy_revision_spec.rb
+++ b/spec/functional/resource/deploy_revision_spec.rb
@@ -45,7 +45,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
before(:all) do
@ohai = Ohai::System.new
- @ohai.all_plugins("os")
+ @ohai.all_plugins(@ohai.all_plugins(["platform", "os"]))
end
let(:node) do
diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb
index 4f462b7cb6..9d3b82f19e 100644
--- a/spec/functional/resource/git_spec.rb
+++ b/spec/functional/resource/git_spec.rb
@@ -92,7 +92,7 @@ E
before(:all) do
@ohai = Ohai::System.new
- @ohai.all_plugins("os")
+ @ohai.all_plugins(["platform", "os"])
end
context "working with pathes with special characters" do