ash*_*her 46 apt apt-get chef-infra vagrant
现在我的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
Run Code Online (Sandbox Code Playgroud)
为了安装添加到我的recipe_list的软件,我需要让VM 在安装其他软件之前发布apt-get更新.
我的印象是,这是'apt'配方的一个特点 - 它会首先运行更新.
我做流浪汉时的输出是:
[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
Run Code Online (Sandbox Code Playgroud)
rta*_*oni 31
您可以在一开始就包含apt配方:
include_recipe 'apt'
Run Code Online (Sandbox Code Playgroud)
这将运行更新命令.
Gab*_*ans 21
apt-get update应该先按照你的方式运行.但是,配方只会每24小时更新一次:
execute "apt-get-update-periodic" do
command "apt-get update"
ignore_failure true
only_if do
File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
end
end
Run Code Online (Sandbox Code Playgroud)
jmo*_*oss 10
有三种资源可以在ubuntu系统上很好地完成,特别是在12.04精确64位上使用.
当其他食谱需要时,随意运行apt-get-update
安装update-notifier-common软件包,为我们提供更新时间戳
检查时间戳并定期更新.在这种情况下,在86400秒之后.
这是三个食谱.
execute "apt-get-update" do
command "apt-get update"
ignore_failure true
action :nothing
end
package "update-notifier-common" do
notifies :run, resources(:execute => "apt-get-update"), :immediately
end
execute "apt-get-update-periodic" do
command "apt-get update"
ignore_failure true
only_if do
File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
end
end
Run Code Online (Sandbox Code Playgroud)
看起来最新版本的opscode apt cookbook允许您在编译时运行它.
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
chef.json = { "apt" => {"compiletime" => true} }
end
Run Code Online (Sandbox Code Playgroud)
只要apt在运行列表中的其他编译时间烹饪书(如postgres)之前运行,这应该可行.
我似乎能够通过应用以下补丁来解决该问题:
https://github.com/wil/cookbooks/commit/a470a4f68602ec3bf3374830f4990a7e19e9de81
| 归档时间: |
|
| 查看次数: |
41275 次 |
| 最近记录: |