How to use resource bash in chef handlers?
here’s my code
require 'chef/log' require 'chef/resource/bash' module Test module Handlers class Notify < Chef::Handler include Chef::Mixin::ShellOut def report require 'chef/resource/bash' if success? Chef::Log.info('Running Updated Resources handler after successful chef-client run') else Chef::Log.info('Running Updated Resources handler after failed chef-client run') end Chef::Log.info('Updated resources are:') updated_resources.each do |resource| Chef::Log.info(resource.to_s) end end end end end
Not sure I entirely understand the question, you wouldn’t use the Chef DSL (bash resource) inside a handler - that would only be something you’d want to use in the recipe. If you want to shell out you already have that ability without needing the Chef DSL.