diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-11-20 22:30:24 -0800 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-11-20 22:30:24 -0800 |
commit | 0385742d677f24c10e741acd4e6f42451ae101f0 (patch) | |
tree | e6f44a97d8584001b870daf0e201f1a4afcf2f88 | |
parent | 80767d09852523018c7d738a7edfb6c66c1b436c (diff) | |
download | chef-sersut/basic-audit-tests.tar.gz |
More meaningful audit_mode configuration values.sersut/basic-audit-tests
-rw-r--r-- | lib/chef/application/client.rb | 10 | ||||
-rw-r--r-- | lib/chef/application/solo.rb | 4 | ||||
-rw-r--r-- | lib/chef/audit/audit_reporter.rb | 3 | ||||
-rw-r--r-- | lib/chef/client.rb | 9 | ||||
-rw-r--r-- | lib/chef/config.rb | 4 |
5 files changed, 22 insertions, 8 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index 5463f504bc..6ca674d287 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 16b0c59259..7dd3dcbaa3 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -205,8 +205,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 ae37b5f8fa..42d7c86c60 100644 --- a/lib/chef/audit/audit_reporter.rb +++ b/lib/chef/audit/audit_reporter.rb @@ -30,7 +30,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 @@ -78,7 +77,7 @@ class Chef end def auditing_enabled? - @audit_enabled + Chef::Config[:audit_mode] != :disabled end private diff --git a/lib/chef/client.rb b/lib/chef/client.rb index b27a2b693d..81173fd4f6 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -441,8 +441,13 @@ class Chef run_context = setup_run_context - converge_error = converge_and_save(run_context) unless (Chef::Config[:audit_mode] == true) - audit_error = run_audits(run_context) unless (Chef::Config[:audit_mode] == false) + if Chef::Config[:audit_mode] != :audit_only + converge_error = converge_and_save(run_context) + end + + if Chef::Config[:audit_mode] != :disabled + audit_error = run_audits(run_context) + end if converge_error || audit_error e = Chef::Exceptions::RunFailedWrappingError.new(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 |