Vagrant 我可以将chef.json的部分内容移动到数据包中吗?

Vagrant 我可以将chef.json的部分内容移动到数据包中吗?,vagrant,chef-infra,chef-solo,berkshelf,vagrantfile,Vagrant,Chef Infra,Chef Solo,Berkshelf,Vagrantfile,我使用的是流浪汉+厨师独奏+巴克书架插件。在我的流浪者档案中,我有这样一个: chef.json = { "postgresql" => { "password" => { "postgres" => "password" } }, "database" => { "create" => ["chembl_18"] }, "build_essential" => { "compiletime" =

我使用的是流浪汉+厨师独奏+巴克书架插件。在我的流浪者档案中,我有这样一个:

chef.json = {
  "postgresql" => {
    "password" => {
      "postgres" => "password"
    }
  },
  "database" => {
    "create" => ["chembl_18"]
  },
  "build_essential" => {
    "compiletime" => true
  }
}
如果我在这里添加更多配置,我的流浪文件将很快变得凌乱。我试图实现这一点,因此我创建了
databags/postgresql/json_attribs.json
文件,其中包含以下内容:

{
  "postgresql": {
    "password": {
      "postgres": "iloverandompasswordsbutthiswilldo"
    }
  }
}
并修改了我的文件中的内容:

chef.json = {
  :postgresql => ["json_attribs"],
  "database" => {
    "create" => ["chembl_18"]
  },
...
}
但它不起作用,我得到:

==> default:  58>>   default['postgresql']['dir'] = "/etc/postgresql/#{node['postgresql']['version']}/main"
...
==> default: [2014-05-14T12:36:51+00:00] ERROR: Running exception handlers
==> default: [2014-05-14T12:36:51+00:00] ERROR: Exception handlers complete
==> default: [2014-05-14T12:36:51+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2014-05-14T12:36:51+00:00] FATAL: TypeError: can't convert String into Integer

因此,我应该如何以及在何处放置这些设置,以便将它们拆分为几个单独的文件?

不,您不能在不更改配方代码的情况下将其移动到数据包中

属性(通过vagrant配置提供)与数据包不同,数据包也存储JSON数据。数据包中的数据只是在Chef服务器中“随处可见”,直到您在烹饪书中明确阅读它

可以通过
search()
data\u-bag()
data\u-bag\u-item()
功能读取数据包,请参阅

为避免使您的
文件凌乱,您应该使用或