Question

I'm trying to extend Bash resource, so that when I invoke shm_wbash, the command's output is placed in a log file as it runs. Since I don't want to copy all the available parameters to LWRP resource definition, I've tried to extend the original chef Bash resource like this (I'll be omitting the actual payload since that doesn't matter here):

class Chef
  class Resource
    class WBash < Resource::Bash
      def initialize(name, run_context=nil)
        super

        puts 123
      end
    end
  end
end

I've put that to cookbooks/shm/libraries/wbash.rb and when I try to run it, I get No resource or method named 'shm_wbash' forChef::Recipe "test"'`. How do I fix this?

Was it helpful?

Solution

Use w_bash

This is what chef is converting the class name to for use in the DSL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top