Reload an ohai plugin from within a LWRP


#1

Hi All,

Does anyone know how to trigger the reload on an OHAI plugin from within a LWRP?

I know we could do it with notifies within a resource in a recipe, but I’d rather have it happen without the notifies…

Wade Peacock
Production IT - Automation/System Engineer | Vision Critical
direct +1.604.629.9358 mobile +1.604.363.8137
web visioncritical.comhttp://www.visioncritical.com/ | @VisionCritical on Twitterhttps://twitter.com/visioncritical | Visit Vision Critical on LinkedInhttp://www.linkedin.com/company/vision-critical

New York | London | Hong Kong | Vancouver | Paris | San Francisco | Sydney | Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa | Detroit
Click here to watch our clients share their Vision Critical successes: www.visioncritical.com/client-storieshttp://www.visioncritical.com/client-stories


#2

Hi,

The “ohai” resource itself is really tiny, there isn’t much to it:


(resource code)

(provider code)

So, check out use_inline_resources so you can just use the ohai
resource as usual, see:

Alternatively, if you like some Ruby code, you can also try this
(inside chef-shell session):

chef:recipe > o = Chef::Resource::Ohai.new(‘reload-etc-plugin’, run_context)
=> <ohai[reload-etc-plugin] @name: “reload-etc-plugin” @noop: nil
@before: nil @params: {} @provider: nil @allowed_actions: [:nothing,
:reload] @action: :reload @updated: false @updated_by_last_action:
false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2
@source_line: nil @guard_interpreter: :default @elapsed_time: 0
@sensitive: false @resource_name: :ohai @plugin: nil>
chef:recipe > o.plugin(‘etc’)
=> "etc"
chef:recipe > o.run_action(:reload)
=> nil
chef:recipe >

Hope this helps.

Best,
Krzysztof

On 10 December 2014 at 23:37, Wade Peacock
Wade.Peacock@visioncritical.com wrote:

Hi All,

Does anyone know how to trigger the reload on an OHAI plugin from within a
LWRP?

I know we could do it with notifies within a resource in a recipe, but I’d
rather have it happen without the notifies…

Wade Peacock

Production IT - Automation/System Engineer | Vision Critical

direct +1.604.629.9358 mobile +1.604.363.8137

web visioncritical.com | @VisionCritical on Twitter | Visit Vision
Critical on LinkedIn

New York | London | Hong Kong | Vancouver | Paris | San Francisco | Sydney |
Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa | Detroit

Click here to watch our clients share their Vision Critical successes:
www.visioncritical.com/client-stories


#3

This did the trick

https://docs.chef.io/lwrp_custom_provider.html#use-inline-resources

Thanks for the tip.

Wade Peacock
Production IT - Automation/System Engineer | Vision Critical
direct +1.604.629.9358 mobile +1.604.363.8137
web visioncritical.com | @VisionCritical on Twitter | Visit Vision Critical on LinkedIn

New York | London | Hong Kong | Vancouver | Paris | San Francisco | Sydney | Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa | Detroit

Click here to watch our clients share their Vision Critical successes: www.visioncritical.com/client-stories

-----Original Message-----
From: kswilczynski@gmail.com [mailto:kswilczynski@gmail.com] On Behalf Of Krzysztof Wilczynski
Sent: Wednesday, December 10, 2014 3:57 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Reload an ohai plugin from within a LWRP

Hi,

The “ohai” resource itself is really tiny, there isn’t much to it:


(resource code)

(provider code)

So, check out use_inline_resources so you can just use the ohai resource as usual, see:

Alternatively, if you like some Ruby code, you can also try this (inside chef-shell session):

chef:recipe > o = Chef::Resource::Ohai.new(‘reload-etc-plugin’, run_context) => <ohai[reload-etc-plugin] @name: “reload-etc-plugin” @noop: nil
@before: nil @params: {} @provider: nil @allowed_actions: [:nothing, :reload] @action: :reload @updated: false @updated_by_last_action:
false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2
@source_line: nil @guard_interpreter: :default @elapsed_time: 0
@sensitive: false @resource_name: :ohai @plugin: nil> chef:recipe > o.plugin(‘etc’) => "etc"
chef:recipe > o.run_action(:reload)
=> nil
chef:recipe >

Hope this helps.

Best,
Krzysztof

On 10 December 2014 at 23:37, Wade Peacock Wade.Peacock@visioncritical.com wrote:

Hi All,

Does anyone know how to trigger the reload on an OHAI plugin from
within a LWRP?

I know we could do it with notifies within a resource in a recipe, but
I’d rather have it happen without the notifies…

Wade Peacock

Production IT - Automation/System Engineer | Vision Critical

direct +1.604.629.9358 mobile +1.604.363.8137

web visioncritical.com | @VisionCritical on Twitter | Visit Vision
Critical on LinkedIn

New York | London | Hong Kong | Vancouver | Paris | San Francisco |
Sydney | Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa |
Detroit

Click here to watch our clients share their Vision Critical successes:
www.visioncritical.com/client-stories