summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-03-27 13:12:28 -0700
committerdanielsdeleo <dan@getchef.com>2015-03-27 14:54:25 -0700
commit4827c9d31e68eafdff8d865d40479a18e6382793 (patch)
treeb1d632eed5b1c784eae9ac763eea5c6886f47acf /lib/chef
parent0a089f77adcf988fb43858ae0c446c31ab4727e5 (diff)
downloadchef-minimal-ohai-mode.tar.gz
Add minimal ohai mode option flagminimal-ohai-mode
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/application/apply.rb5
-rw-r--r--lib/chef/application/client.rb5
-rw-r--r--lib/chef/application/solo.rb5
-rw-r--r--lib/chef/client.rb3
-rw-r--r--lib/chef/config.rb5
5 files changed, 22 insertions, 1 deletions
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index 42805001d8..e9768b218c 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -85,6 +85,11 @@ class Chef::Application::Apply < Chef::Application
:default => !Chef::Platform.windows?,
:description => "Use colored output, defaults to enabled"
+ option :minimal_ohai,
+ :long => "--minimal-ohai",
+ :description => "Only run the bare minimum ohai plugins chef needs to function",
+ :boolean => true
+
attr_reader :json_attribs
def initialize
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 03fd07e9f0..9984ad5b9d 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -253,6 +253,11 @@ class Chef::Application::Client < Chef::Application
:description => "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`",
:proc => lambda { |mo| mo.gsub("-", "_").to_sym }
+ option :minimal_ohai,
+ :long => "--minimal-ohai",
+ :description => "Only run the bare minimum ohai plugins chef needs to function",
+ :boolean => true
+
IMMEDIATE_RUN_SIGNAL = "1".freeze
attr_reader :chef_client_json
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 97a1952d0f..dd09d65b42 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -180,6 +180,11 @@ class Chef::Application::Solo < Chef::Application
:description => "Set maximum duration to wait for another client run to finish, default is indefinitely.",
:proc => lambda { |s| s.to_i }
+ option :minimal_ohai,
+ :long => "--minimal-ohai",
+ :description => "Only run the bare minimum ohai plugins chef needs to function",
+ :boolean => true
+
attr_reader :chef_client_json
def initialize
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index f5cde4bfb3..a4f15c271f 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -272,7 +272,8 @@ class Chef
end
def run_ohai
- ohai.all_plugins
+ filter = Chef::Config[:minimal_ohai] ? %w[fqdn machinename hostname platform platform_version os os_version] : nil
+ ohai.all_plugins(filter)
@events.ohai_completed(node)
end
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index a9fa9f1552..b897f9fdbd 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -333,6 +333,11 @@ class Chef
# This can be removed when audit-mode is enabled by default.
default :audit_mode, :disabled
+ # Chef only needs ohai to run the hostname plugin for the most basic
+ # functionality. If the rest of the ohai plugins are not needed (like in
+ # most of our testing scenarios)
+ default :minimal_ohai, false
+
# 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
# expanding the run list and having the server compute the cookbook version