如何让 Chef 在运行其他食谱之前运行 apt-get update [英] How can I get Chef to run apt-get update before running other recipes

查看:22
本文介绍了如何让 Chef 在运行其他食谱之前运行 apt-get update的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我的 Vagrantfile 中有以下内容:

config.vm.provision :chef_solo do |chef|Chef.cookbooks_path = "食谱"Chef.add_recipe "apt"Chef.add_recipe "构建必备"Chef.add_recipe "chef-redis::source"Chef.add_recipe "openssl"Chef.add_recipe "git"Chef.add_recipe "postgresql::server"Chef.add_recipe "postgresql::client"结尾

为了安装添加到我的 recipe_list 的软件,我需要让 VM 在安装其他软件之前发出 apt-get update.

我的印象是,这是apt"配方的一个特点——它会首先运行更新.

当我做一个 vagrant provision 时的输出是:

[2012 年 2 月 11 日星期六 22:20:03 -0800] 信息:*** Chef 0.10.2 ***[2012 年 2 月 11 日星期六 22:20:03 -0800] 信息:将 run_list 设置为 ["recipe[apt]"、"recipe[build-essential]"、"recipe[chef-redis::source]"、"配方[openssl]"、配方[git]"、配方[postgresql::server]"、配方[postgresql::client]"、配方[vagrant-main]"] 来自JSON[2012 年 2 月 11 日星期六 22:20:03 -0800] 信息:运行列表是 [recipe[apt]、recipe[build-essential]、recipe[chef-redis::source]、recipe[openssl]、recipe[git]],配方[postgresql::server],配方[postgresql::client],配方[vagrant-main]][2012 年 2 月 11 日星期六 22:20:03 -0800] 信息:运行列表扩展为 [apt、build-essential、chef-redis::source、openssl、git、postgresql::server、postgresql::client、vagrant-主要的][2012 年 2 月 11 日星期六 22:20:03 -0800] 信息:启动 Chef Run for lucid32[2012 年 2 月 11 日星期六 22:20:03 -0800] 信息:处理包 [postgresql-client] 操作安装(postgresql::client 第 37 行)[2012 年 2 月 11 日星期六 22:20:04 -0800] 错误:包 [postgresql-client](postgresql::client 第 37 行)出现错误[2012 年 2 月 11 日星期六 22:20:04 -0800] 错误:运行异常处理程序[2012 年 2 月 11 日星期六 22:20:04 -0800] 错误:异常处理程序完成[2012 年 2 月 11 日星期六 22:20:04 -0800] 致命:堆栈跟踪转储到/tmp/vagrant-chef-1/chef-stacktrace.out[2012 年 2 月 11 日星期六 22:20:04 -0800] 致命:Chef::Exceptions::Exec: package[postgresql-client](postgresql::client line 37)有一个错误:apt-get -q -y installpostgresql-client=8.4.8-0ubuntu0.10.04 返回 100,预期为 0

解决方案

我似乎可以通过应用以下补丁来解决该问题:

https://github.com/wil/cookbooks/commit/a470a4f68602ec3bf3374830f4990a7e19e9de81"/p>

Right now I have the following in my Vagrantfile:

config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "cookbooks"
    chef.add_recipe "apt"
    chef.add_recipe "build-essential"
    chef.add_recipe "chef-redis::source"
    chef.add_recipe "openssl"
    chef.add_recipe "git"
    chef.add_recipe "postgresql::server"
    chef.add_recipe "postgresql::client"
end

In order to install the software added to my recipe_list, I need to get the VM to issue an apt-get update before installing the other software.

I was under the impression that this was one of the features of the 'apt' recipe - that it would run the update first thing.

The output when I do a vagrant provision is:

[Sat, 11 Feb 2012 22:20:03 -0800] INFO: *** Chef 0.10.2 ***
[Sat, 11 Feb 2012 22:20:03 -0800] INFO: Setting the run_list to ["recipe[apt]", "recipe[build-essential]", "recipe[chef-redis::source]", "recipe[openssl]", "recipe[git]", "recipe[postgresql::server]", "recipe[postgresql::client]", "recipe[vagrant-main]"] from JSON
[Sat, 11 Feb 2012 22:20:03 -0800] INFO: Run List is [recipe[apt], recipe[build-essential], recipe[chef-redis::source], recipe[openssl], recipe[git], recipe[postgresql::server], recipe[postgresql::client], recipe[vagrant-main]]
[Sat, 11 Feb 2012 22:20:03 -0800] INFO: Run List expands to [apt, build-essential, chef-redis::source, openssl, git, postgresql::server, postgresql::client, vagrant-main]
[Sat, 11 Feb 2012 22:20:03 -0800] INFO: Starting Chef Run for lucid32
[Sat, 11 Feb 2012 22:20:03 -0800] INFO: Processing package[postgresql-client] action install (postgresql::client line 37)
[Sat, 11 Feb 2012 22:20:04 -0800] ERROR: package[postgresql-client] (postgresql::client line 37) has had an error
[Sat, 11 Feb 2012 22:20:04 -0800] ERROR: Running exception handlers
[Sat, 11 Feb 2012 22:20:04 -0800] ERROR: Exception handlers complete
[Sat, 11 Feb 2012 22:20:04 -0800] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[Sat, 11 Feb 2012 22:20:04 -0800] FATAL: Chef::Exceptions::Exec: package[postgresql-client] (postgresql::client line 37) had an error: apt-get -q -y install postgresql-client=8.4.8-0ubuntu0.10.04 returned 100, expected 0

解决方案

I seem to have been able to solve the issue by applying the following patch:

https://github.com/wil/cookbooks/commit/a470a4f68602ec3bf3374830f4990a7e19e9de81

这篇关于如何让 Chef 在运行其他食谱之前运行 apt-get update的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆