chef - Library doesn't process "DSL" for 'execute' -


can me please?

nomethoderror ------------- undefined method `execute' chat::mattermost:class 

relevant file content: (file name libraries/chat.rb)

4: 5:  module chat 6:    class mattermost 7: 8:      def self.log_to_chat(message) 9>>       execute "echo" 10:          command "echo #{message}" 11:        end 12:      end 13: 14:    end 15:  end 16: 

i read dsl syntax isn't available in definition, guessing need resembling r = chef::resource::execute.new("echo #{message}") , r.run_command :run i'm not quite sure how it.

other relevant code, method "called" this:

log "this message"   level :info   notifies :run, chat::mattermost.log_to_chat("#{name}"), :immediately end 

edit: second attempt

nomethoderror ------------- undefined method `events' nil:nilclass 

for code:

5:  require 'chef/resource/execute' 6: 7:  module chat 8:    class mattermost 9: 10:      def self.log_to_chat(message) 11:        cmd = chef::resource::execute.new("echo #{message}") 12>>       cmd.run_action(:run) 13: 

notifies :run, chat::mattermost.log_to_chat("#{name}"), :immediately 
  1. you can't call notify on non-resource.
  2. you can't create resource dynamically calling notifies, won't work.
  3. as second parameter (when called resource block) notifies should pass string used search resource in chef context.

if want enhance log resource provider, should implement own, similar this, put in libraries , call log resource newly implemented class name provider.

log 'this message'   provider chef::provider::log::mycustomlog end 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -