diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-09-15 10:21:41 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-09-15 14:37:49 -0700 |
commit | e4db9c3f4edc696274786187967006273c2c8652 (patch) | |
tree | ede4267e81c591ffd49f52dd9090520044c8ce9d | |
parent | c836de02db7ae6edd5ab6f8ea2a585213ae4bf46 (diff) | |
download | chef-e4db9c3f4edc696274786187967006273c2c8652.tar.gz |
Add examples to the ohai resource
Make it a bit easier to generate the docs for this resource
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/ohai.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb index 02c91b8d8a..0aa1d947d6 100644 --- a/lib/chef/resource/ohai.rb +++ b/lib/chef/resource/ohai.rb @@ -31,6 +31,49 @@ class Chef 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." + examples <<~DOC + Reload All Ohai Plugins + + ```ruby + ohai 'reload' do + action :reload + end + ``` + + Reload A Single Ohai Plugins + + ```ruby + ohai 'reload' do + plugin 'cloud' + action :reload + end + ``` + + Reload Ohai after a new user is created + + ```ruby + ohai 'reload_passwd' do + action :nothing + plugin 'etc' + end + + user 'daemonuser' 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']['daemonuser']['uid'] + puts node['etc']['passwd']['daemonuser']['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." |