diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-11-20 22:30:24 -0800 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-11-21 14:58:03 -0800 |
commit | 5785b62c35c961d811c0b5e43f9fffbfcadb3bc7 (patch) | |
tree | a15b0d2d23457c516af22eefdae72246fe02c1dc | |
parent | 3aa7ffda1bd3664a3ecc7090b379a88690711a7f (diff) | |
download | chef-5785b62c35c961d811c0b5e43f9fffbfcadb3bc7.tar.gz |
More meaningful audit_mode configuration values.
-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 | 8 | ||||
-rw-r--r-- | lib/chef/config.rb | 4 |
5 files changed, 17 insertions, 12 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 f433317826..798834304c 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -207,8 +207,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 510dcd342f..2a9d44a3c5 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 |