厨师食谱没有在另一本食谱中看到被覆盖的属性

时间:2015-07-31 10:53:24

标签: attributes vagrant chef chef-solo

我有一个像[ recipe["git_deploy"], recipe["my_role_cookbook"] ]这样的run_list 我在my_role_cookbook的default.rb配方中设置了git_deploy所需的属性。但是,git_deploy并没有获得这些属性。 如果我将git_deploy所需的属性放在my_role_cookbook / attributes / default.rb中,那么它可以工作。如果我把懒惰的评估放在git_deploy中 - 它也可以 如果我在my_rolecook_book/recipes/default.rb

中使用node.override,我不明白为什么它不起作用

更大的图片:我有三个环境,在my_role的角色文件中,我有这样的env_run_lists:

"production" => ["recipe[git_deploy]","recipe[my_role]"],
"staging" =>["recipe[git_deploy]","recipe[my_role]"],
"develop" => ["recipe[my_role]"]

修改
在两本烹饪书中使用debug_value之后:

  • 在git_deploy中使用延迟评估时(my_role_cookbook / recipe / default.rb中使用的node.override):

    • Chef ::来自git_deploy的日志输出
      [2015-07-31T11:44:12+00:00] FATAL: [["set_unless_enabled?", false], ["default", :not_present], ["env_default", :not_present], ["role_default", :not_present], ["force_default", :not_present], ["normal", :not_present], ["override", :not_present], ["role_override", :not_present], ["env_override", :not_present], ["force_override", :not_present], ["automatic", :not_present]]
    • 来自my_role_cookbook的日志输出
      [2015-07-31T11:44:12+00:00] FATAL: [["set_unless_enabled?", false], ["default", :not_present], ["env_default", :not_present], ["role_default", :not_present], ["force_default", :not_present], ["normal", :not_present], ["override", "youtube-minion"], ["role_override", :not_present], ["env_override", :not_present], ["force_override", :not_present], ["automatic", :not_present]]
  • 不使用延迟评估时(my_role_cookbook中只有node.override)

    • 来自git_deploy的日志。在使用debug_value的日志之后,git_deploy失败并显示undefined method `[]' for nil:NilClass

    [2015-07-31T11:45:53+00:00] FATAL: [["set_unless_enabled?", false], ["default", :not_present], ["env_default", :not_present], ["role_default", :not_present], ["force_default", :not_present], ["normal", :not_present], ["override", :not_present], ["role_override", :not_present], ["env_override", :not_present], ["force_override", :not_present], ["automatic", :not_present]]

    • 来自my_role_cookbook的日志 - 未显示此LOG,因为上一个配方失败。

1 个答案:

答案 0 :(得分:0)

在运行任何配方之前,合并并评估attributes/*内的所有文件。由于您已将git_deploy放在首次列入运行列表中,因此它的配方会在您的运行列表之前运行。您必须使用属性文件才能在git deploy的配方之前注入属性,然后运行您的配方。或者将git_deploy作为食谱中的包含。

这是how attribute files work上有更多内容的链接。

相关问题