【发布时间】:2015-07-31 21:30:40
【问题描述】:
我有一个这样的 run_list [ recipe["git_deploy"], recipe["my_role_cookbook"] ]
我在 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]]
- Chef::git_deploy 的日志输出
-
不使用惰性求值时(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 的日志 - 此日志未显示,因为之前的配方失败。
- 来自 git_deploy 的日志。在带有 debug_value 的日志之后,git_deploy 失败并显示
【问题讨论】:
-
试试debug_value。
-
感谢您的提示。我添加了命令的输出。
标签: attributes vagrant chef-infra chef-solo