summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-09-15 14:44:40 -0700
committerGitHub <noreply@github.com>2020-09-15 14:44:40 -0700
commit7b26813bd6684bf208c805a6b22f033d32a0b91f (patch)
treeaea56609af26c0c789429172e126796975337a24
parentc349ff9f1dacd6ae3cf2c352c99c98cbe8ce45fe (diff)
parentafded16a4edb42d6c4aff90e2326d55029e98e4c (diff)
downloadchef-7b26813bd6684bf208c805a6b22f033d32a0b91f.tar.gz
Merge pull request #10432 from chef/ohai
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/ohai.rb47
-rwxr-xr-xtasks/docs.rb8
2 files changed, 46 insertions, 9 deletions
diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb
index 02c91b8d8a..560a15353a 100644
--- a/lib/chef/resource/ohai.rb
+++ b/lib/chef/resource/ohai.rb
@@ -29,10 +29,53 @@ class Chef
provides :ohai
- description "Use the **ohai** resource to reload the Ohai configuration on a node. This allows recipes that change system attributes (like a recipe that adds a user) to refer to those attributes later on during the #{ChefUtils::Dist::Infra::CLIENT} run."
+ description "Use the **ohai** resource to reload the Ohai configuration on a node. This allows recipes that change system attributes (like a recipe that adds a user) to refer to those attributes later on during the #{ChefUtils::Dist::Infra::PRODUCT} run."
+
+ examples <<~DOC
+ Reload All Ohai Plugins
+
+ ```ruby
+ ohai 'reload' do
+ action :reload
+ end
+ ```
+
+ Reload A Single Ohai Plugin
+
+ ```ruby
+ ohai 'reload' do
+ plugin 'ipaddress'
+ action :reload
+ end
+ ```
+
+ Reload Ohai after a new user is created
+
+ ```ruby
+ ohai 'reload_passwd' do
+ action :nothing
+ plugin 'etc'
+ end
+
+ user 'daemon_user' do
+ home '/dev/null'
+ shell '/sbin/nologin'
+ system true
+ notifies :reload, 'ohai[reload_passwd]', :immediately
+ end
+
+ ruby_block 'just an example' do
+ block do
+ # These variables will now have the new values
+ puts node['etc']['passwd']['daemon_user']['uid']
+ puts node['etc']['passwd']['daemon_user']['gid']
+ end
+ end
+ ```
+ DOC
property :plugin, String,
- description: "The name of an Ohai plugin to be reloaded. If this property is not specified, #{ChefUtils::Dist::Infra::PRODUCT} will reload all plugins."
+ description: "Specific Ohai attribute data to reload. This property behaves similar to specifying attributes when running Ohai on the command line and takes the attribute that you wish to reload instead of the actual plugin name. For instance, you can pass `ipaddress` to reload `node['ipaddress']` even though that data comes from the `Network` plugin. If this property is not specified, #{ChefUtils::Dist::Infra::PRODUCT} will reload all plugins."
def load_current_resource
true
diff --git a/tasks/docs.rb b/tasks/docs.rb
index 586115f2f9..ff5a38afda 100755
--- a/tasks/docs.rb
+++ b/tasks/docs.rb
@@ -190,13 +190,7 @@ namespace :docs_site do
properties["properties_resources_common_windows_security"] = true if %w{cookbook_file file template remote_file directory}.include?(name)
- properties["properties_shortcode"] =
- case name
- when "ohai"
- "resource_ohai_properties.md"
- when "log"
- "resource_log_properties.md"
- end
+ properties["properties_shortcode"] = "resource_log_properties.md" if name == "log"
properties["ps_credential_helper"] = true if name == "dsc_script"