配置流浪盒需要多次尝试

时间:2015-01-19 23:30:53

标签: vagrant chef vagrantfile chef-zero

  

“疯狂:一遍又一遍地做同样的事情,期待着   不同的结果。“ - 阿尔伯特爱因斯坦

我有一个流浪汉+厨师(w / chef-zero Berkshelf)内置框,可以运行很多程序,包括zend-server-php,mongos和erlang。我正在使用流行的食谱,用Berkshelf管理,以及一个基本的CentOS 6盒子(存储在我的本地Mac上)。第一次启动此框(在vagrant destroy之后)通常需要多次尝试。 vagrant up将在上面列出的某个程序上失败,我将不得不一遍又一遍地运行vagrant provision(有时多达6次)以完成整个构建而没有错误。然而,在极少数情况下,星星会对齐并且一切都会在第一次尝试时闪现。

我看到的错误通常是显式超时错误(尽管并非总是如此)。我通常从一个相当弱的办公网络连接(<20 Mbps以下)运行它,这可以解释为什么失败发生在最大的下载。

所以这是我的问题:首先,除了网络连接之外还有其他一些变量可以解释为什么我需要多次vagrant provision吗?如果是这样,我该如何测试和治疗呢?第二,有没有办法让流浪汉保持供应,直到成功完成?我没有找到这样做的文件标记/设置,但感觉可能有一个......

感谢您的帮助。

更新

以下是zend-server-php-5.4失败的示例:

==> mongos-zend: Running triggers before provision...
the ffi-yajl and yajl-ruby gems have incompatible C libyajl libs and should not be loaded in the same Ruby VM
falling back to ffi which might work (or might not, no promises)
Loading cookbooks from chef-repo/cookbooks
Uploading Cookbook apt
Uploading Cookbook build-essential
Uploading Cookbook cb-platform
Uploading Cookbook chef-sugar
Uploading Cookbook erlang
Uploading Cookbook hostsfile
Uploading Cookbook mongodb
Uploading Cookbook mysql
Uploading Cookbook openssl
Uploading Cookbook percona
Uploading Cookbook postgresql
Uploading Cookbook python
Uploading Cookbook rabbitmq
Uploading Cookbook rbac
Uploading Cookbook resource-control
Uploading Cookbook role-mongodb-configserver
Uploading Cookbook role-mongodb-mongos
Uploading Cookbook role-mongodb-replicaset1
Uploading Cookbook role-mongodb-replicaset2
Uploading Cookbook role-mongodb-shard1
Uploading Cookbook role-mongodb-shard2
Uploading Cookbook role-rabbitmq
Uploading Cookbook role-sphinx
Uploading Cookbook role-twemcache
Uploading Cookbook role-zendserver
Uploading Cookbook runit
Uploading Cookbook smf
Uploading Cookbook sphinx
Uploading Cookbook yum
Uploading Cookbook yum-epel
Uploading Cookbook yum-erlang_solutions
Uploading Cookbook yum-mysql-community
Uploading Cookbook zendserver
==> mongos-zend: Chef 12.0.3 Omnibus package is already installed.
==> mongos-zend: Running provisioner: shell...
    mongos-zend: Running: inline script
==> mongos-zend: Running provisioner: chef_client...
==> mongos-zend: Creating folder to hold client key...
==> mongos-zend: Uploading chef client validation key...
Generating chef JSON and uploading...
==> mongos-zend: Running chef-client...
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: Forking chef instance to converge...
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: *** Chef 11.10.4 ***
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: Chef-client pid: 13175
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Setting the run_list to ["recipe[role-mongodb-mongos::default]", "recipe[role-zendserver::default]", "recipe[role-rabbitmq::default]", "recipe[role-twemcache::default]", "recipe[role-sphinx::default]", "recipe[cb-platform::default]"] from JSON
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Run List is [recipe[role-mongodb-mongos::default], recipe[role-zendserver::default], recipe[role-rabbitmq::default], recipe[role-twemcache::default], recipe[role-sphinx::default], recipe[cb-platform::default]]
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Run List expands to [role-mongodb-mongos::default, role-zendserver::default, role-rabbitmq::default, role-twemcache::default, role-sphinx::default, cb-platform::default]
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Starting Chef Run for mongos-zend
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Running start handlers
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Start handlers complete.
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: HTTP Request Returned 404 Not Found : Object not found: /reports/nodes/mongos-zend/runs
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Loading cookbooks [apt, build-essential, cb-platform, chef-sugar, erlang, hostsfile, mongodb, mysql, openssl, percona, postgresql, python, rabbitmq, rbac, role-mongodb-mongos, role-rabbitmq, role-sphinx, role-twemcache, role-zendserver, runit, smf, sphinx, yum, yum-epel, yum-erlang_solutions, yum-mysql-community, zendserver]
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: CentOS doesn't provide mongodb, forcing use of mongodb-org repo
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: 10gen_repo is deprecated, use mongodb_org_repo
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Cloning resource attributes for package[mongo-10gen-server] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Previous package[mongo-10gen-server]: /var/chef/cache/cookbooks/role-mongodb-mongos/recipes/default.rb:15:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Current  package[mongo-10gen-server]: /var/chef/cache/cookbooks/mongodb/recipes/install.rb:65:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Cloning resource attributes for template[/etc/mongodb.conf] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Previous template[/etc/mongodb.conf]: /var/chef/cache/cookbooks/mongodb/recipes/install.rb:14:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Current  template[/etc/mongodb.conf]: /var/chef/cache/cookbooks/mongodb/definitions/mongodb.rb:139:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Cloning resource attributes for package[gcc] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Previous package[gcc]: /var/chef/cache/cookbooks/mongodb/recipes/mongo_gem.rb:3:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Current  package[gcc]: /var/chef/cache/cookbooks/role-zendserver/recipes/default.rb:34:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: hostsfile_entry[33.33.33.42] content already matches - nothing to do.
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: hostsfile_entry[33.33.33.43] content already matches - nothing to do.
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: Starting install for package zend-server-php-5.4
==> mongos-zend: [2015-01-20T10:30:22-06:00] INFO: package[zend-server-php-5.4] installing zend-server-php-5.4-6.2.0-2002 from zend-server repository
==> mongos-zend: 
==> mongos-zend: ================================================================================
==> mongos-zend: Error executing action `install` on resource 'package[zend-server-php-5.4]'
==> mongos-zend: ================================================================================
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: Chef::Exceptions::Exec
==> mongos-zend: 
==> mongos-zend: ----------------------
==> mongos-zend:  returned 1, expected 0
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: Resource Declaration:
==> mongos-zend: ---------------------
==> mongos-zend: # In /var/chef/cache/cookbooks/zendserver/recipes/default.rb
==> mongos-zend: 
==> mongos-zend:  65: package package_name do
==> mongos-zend:  66:   :install
==> mongos-zend:  67:   notifies :restart, 'service[zend-server]', :immediate 
==> mongos-zend:  68: end
==> mongos-zend:  69: 
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: Compiled Resource:
==> mongos-zend: ------------------
==> mongos-zend: # Declared in /var/chef/cache/cookbooks/zendserver/recipes/default.rb:65:in `from_file'
==> mongos-zend: 
==> mongos-zend: package("zend-server-php-5.4") do
==> mongos-zend:   action :install
==> mongos-zend:   retries 0
==> mongos-zend:   retry_delay 2
==> mongos-zend:   package_name "zend-server-php-5.4"
==> mongos-zend:   version "6.2.0-2002"
==> mongos-zend:   cookbook_name "zendserver"
==> mongos-zend:   recipe_name "default"
==> mongos-zend: end

1 个答案:

答案 0 :(得分:2)

带宽,CPU,I / O,错误都可能累积到资源收敛时间,这可能会导致超时。尝试增加VM(CPU,RAM)的资源,如果可能的话,在主机上使用SSD等等。

至于运行vagrant provision直到成功,你可能只需将它包装在while循环中:

false; while [ "$?" -ne "0" ]; do vagrant provision; done