【问题标题】:chef attribute will not get over ridden厨师属性不会被覆盖
【发布时间】:2016-02-24 10:15:23
【问题描述】:

我正在运行一个依赖于多个食谱的食谱,其中一个尝试克隆一个 github 存储库并将 url 作为属性提供给它的食谱中的属性/fair.rb (https://github.com/priestjim/chef-openresty/blob/master/attributes/fair.rb):

# For more information checkout https://github.com/gnosek/nginx-upstream-fair
default['openresty']['fair']['url']             = 'git://github.com/gnosek/nginx-upstream-fair.git'

我需要覆盖此属性以提供 https 端点而不是 SSH,因此在我的食谱中,我创建了 attributes/fair.rb 并放下:

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

但是当我使用 vagrant 单独运行 chef 时,它会失败并显示以下内容:

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 端点。知道为什么吗?

【问题讨论】:

  • 运行列表中是否包含食谱中属性被覆盖的食谱?

标签: vagrant chef-infra chef-recipe vagrantfile chef-solo


【解决方案1】:

在你的 openresty 食谱的包装中,确保它依赖于 metadata.rb 中的 openresty。这将确保以正确的顺序加载内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 1970-01-01
    • 2017-08-21
    • 1970-01-01
    • 2023-03-22
    • 2013-05-19
    相关资源
    最近更新 更多