如何扩展厨师资源? [英] How to extend chef resource?

查看:77
本文介绍了如何扩展厨师资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展 Bash 资源,以便在我调用 shm_wbash 时,放置命令的输出在运行时的日志文件中。由于我不想将所有可用参数都复制到LWRP资源定义中,因此我尝试像这样扩展原始的Chef Bash资源(我将省略实际的有效负载,因为在这里无关紧要):

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

我已将其放入烹饪书/ shm /库/ wbash .rb ,当我尝试运行它时,得到的没有资源或方法名为'shm_wbash',用于 Chef :: Recipe test'` 。我该如何解决?

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?

推荐答案

使用 w_bash

这就是厨师将类名转换为用于DSL的方式。

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

这篇关于如何扩展厨师资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆