自定义木偶提供程序:如何从木偶主文件中检索文件

时间:2015-05-07 19:58:14

标签: ruby puppet custom-type

我需要从Pu​​ppet master中的自定义Puppet提供程序中检索静态文件(就像文件内置资源一样)。在Puppet代码中定义单独的内置文件资源不是一种选择。所以,在Puppet代码中,事情应该是这样的:

custom_type{
  property1 => 'value1'
  property2 => 'value2'
  file => "puppet:///${module_name}/somefile"
}

虽然之前我已经编写了自定义类型和提供程序,但是与Puppet master的文件服务器的交互是我无法获得的。

2 个答案:

答案 0 :(得分:2)

I suggest using the class Example { public: Example(); int x; int y; } ... void do_something(Example& ex) { ex.x++; ex.y++; } type after all. You need not do this from the manifest level. Puppet can handle this using generated resources.

For example, the nagios types do something similar.

In your custom type code, introduce a class Example { public: Example(); int x; int y; } ... void do_something(Example* ex) { ex->x++; ex->y++; } hook.

file

The agent takes care of adding this resource to the catalog.

答案 1 :(得分:1)

查看puppet file type,看起来这就是你想要的第103行:

 Puppet::FileServing::Content.indirection.find(metadata.source, :environment => resource.catalog.environment_instance, :links => resource[:links]) 

metadata.source是文件的路径。