chef 属性不会被覆盖

我正在运行一个依赖于多个 recipe 的 recipe,其中一个 recipe 尝试从 cookbook 的 attributes/fair.rb 中克隆 github repo 并将 url 作为属性给出 ( https://github.com/priestjim/chef-openresty/blob/master/attributes/fair.rb) :

# 了解更多信息,请参见 https://github.com/gnosek/nginx-upstream-fair
默认['openresty']['fair']['url']             = 'git://github.com/gnosek/nginx-upstream-fair.git'

我需要覆盖这个属性,以给出 https endpoint 而不是 SSH,所以在我的 cookbook 中,我创建了 attributes/fair.rb 并写下了以下内容:

override['openresty']['fair']['url'] = 'https://github.com/gnosek/nginx-upstream-fair.git'

但是当我使用 vagrant 运行 chef solo 时,它会失败,并显示以下信息:

Mixlib::ShellOut::ShellCommandFailed
==> default:     ------------------------------------
==> default:     Expected process to exit with [0], but received '128'
==> default:     ---- Begin output of git ls-remote "git://github.com/gnosek/nginx-upstream-fair.git" "master*" ----
==> default:     STDOUT:
==> default:     STDERR: fatal: unable to connect to github.com:
==> default:     github.com[0: 192.30.252.131]: errno=Connection timed out
==> default:     ---- End output of git ls-remote "git://github.com/gnosek/nginx-upstream-fair.git" "master*" ----
==> default:     Ran git ls-remote "git://github.com/gnosek/nginx-upstream-fair.git" "master*" returned 128
==> default:
==> default:     Resource Declaration:
==> default:     ---------------------
==> default:     # In /tmp/vagrant-chef/97b7f5ef6e972aa934bfb7ea6a5db3bb/cookbooks/openresty/recipes/fair_module.rb
==> default:
==> default:      26: git module_path do
==> default:      27:   repository node['openresty']['fair']['url']
==> default:      28:   reference 'master'
==> default:      29:   action :checkout
==> default:      30:   not_if { ::File.exists?(module_path) }
==> default:      31: end
==> default:      32:
==> default:
==> default:     Compiled Resource:
==> default:     ------------------
==> default:     # Declared in /tmp/vagrant-chef/97b7f5ef6e972aa934bfb7ea6a5db3bb/cookbooks/openresty/recipes/fair_module.rb:26:in `from_file'
==> default:
==> default:     git("/var/chef/cache/nginx-upstream-fair") do
==> default:       action [:checkout]
==> default:       retries 0
==> default:       retry_delay 2
==> default:       default_guard_interpreter :default
==> default:       destination "/var/chef/cache/nginx-upstream-fair"
==> default:       enable_checkout true
==> default:       revision "master"
==> default:       remote "origin"
==> default:       checkout_branch "deploy"
==> default:       declared_type :git
==> default:       cookbook_name :openresty
==> default:       recipe_name "fair_module"
==> default:       repository "git://github.com/gnosek/nginx-upstream-fair.git"
==> default:       not_if { #code block }
==> default:     end

Ran git ls-remote "git://github.com/gnosek/nginx-upstream-fair.git" "master*" returned 128
==> default: [2016-02-23T01:03:00+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

你可以看到它仍然以某种方式使用 ssh endpoint。有什么想法为什么?

点赞
用户78722
用户78722

在您的 openresty cookbook 包装器中,确保依赖于 metadata.rb 中的 openresty。这将确保正确加载事物。

2016-02-24 02:15:23