我正在尝试创建一个 LWRP,它将调用在其内部定义的资源。我的食谱的结构如下:
在机器说明书的提供者中,我有一个代码片段如下:
require 'chef/provisioning' # driver for creating machines
require '::File'
def get_environment_json
@@environment_template = JSON.parse(File::read(new_resource.template_path + "environment.json"))
return @@environment_template
end
该代码只是试图读取一个 json 文件,我正在使用 File::read 。
我不断收到如下错误:
加载错误
无法加载此类文件 -- ::File
有谁知道我如何在我的 LWRP 提供程序中使用 File::read ?