2015-08-24 1 views
2

Я стараюсь предоставить боксерскую коробку с шеф-поваром Zero. Когда я запускаю vagrant up myboxname, он терпит неудачу с ошибкой 404 на URL-адресе Chef и выходит с ошибкой. Если я затем запустил vagrant provision myboxname, он будет успешным. Есть ли какая-то задержка для запуска локального сервера шеф-повара, и нужно как-то ухаживать за бродягой? Я получаю объект, который не найден в обоих прогонах, но второй работает, почему это происходит?Бродяга с шеф-поваром Нулевая неудача при первоначальном запуске, но успешно с последующим обеспечением

Vagrantfile:

Vagrant.configure("2") do |config| 
    config.chef_zero.enabled = true 
    config.chef_zero.environments = "./environments/_default.json" 
    config.chef_zero.data_bags = "./data_bags/" 
    config.chef_zero.roles = "./roles/" 

    config.vm.define "myboxname" do |machine| 
    machine.chef_zero.cookbooks = ["./cookbooks/mycookbook/"] 
    machine.chef_zero.log_level = "debug" 
    machine.vm.provider "virtualbox" do |vbox| 
     vbox.name = "myboxname" 
    end 
    machine.vm.provision :chef_zero do |chef| 
     chef.data_bags_path = "./data_bags/" 
     chef.run_list = ['recipe[mycookbook::default]'] 
    end 
    end 
end 

Дополнительная информация:

$ vagrant version 
Installed Version: 1.7.4 
$ vagrant plugin list 
vagrant-chef-zero (1.0.1) 
vagrant-share (1.1.4, system) 

Прогон, например, с trusty64:

$ vagrant up myboxname 
Bringing machine 'myboxname' up with 'virtualbox' provider... 
==> myboxname: Importing base box 'ubuntu/trusty64'... 
==> myboxname: Setting the name of the VM: myboxname 
<virtualbox init stuff> 
==> myboxname: Running 'pre-boot' VM customizations... 
==> myboxname: Booting VM... 
==> myboxname: Waiting for machine to boot. This may take a few minutes... 
    myboxname: SSH address: 127.0.0.1:2222 
    myboxname: SSH username: vagrant 
    myboxname: SSH auth method: private key 
    myboxname: Inserting generated public key within guest... 
==> myboxname: Machine booted and ready! 
==> myboxname: Checking for guest additions in VM... 
==> myboxname: Configuring and enabling network interfaces... 
==> myboxname: Mounting shared folders... 
    myboxname: /vagrant => /path/to/my/chef-repo 
    myboxname: /tmp/vagrant-chef/8d6a2619e17bfa48a2eba11cea21e6c6/cookbooks => /path/to/my/chef-repo/cookbooks 
==> myboxname: Running provisioner: chef_zero... 
    myboxname: Installing Chef (latest)... 
Generating chef JSON and uploading... 
==> myboxname: Running chef-client (local-mode)... 
==> myboxname: [2015-08-26T06:26:24+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/vagrant-chef/8d6a2619e17bfa48a2eba11cea21e6c6, /tmp/vagrant-chef/cookbooks 
==> myboxname: One version per cookbook 
==> myboxname: data_bags at /tmp/vagrant-chef/d63293c35eb5900ffff1cf7d76ac6fdd/data_bags 
==> myboxname: [2015-08-26T06:26:24+00:00] INFO: Forking chef instance to converge... 
==> myboxname: Starting Chef Client, version 12.4.1 
==> myboxname: [2015-08-26T06:26:24+00:00] INFO: *** Chef 12.4.1 *** 
==> myboxname: [2015-08-26T06:26:24+00:00] INFO: Chef-client pid: 3080 
==> myboxname: [2015-08-26T06:26:25+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/vagrant-ubuntu-trusty-64 
==> myboxname: [2015-08-26T06:26:25+00:00] ERROR: #<Errno::ENOENT: No such file or directory @ dir_s_mkdir - /tmp/vagrant-chef/cookbooks/nodes> 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:97:in `mkdir' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:97:in `block in create_child' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:95:in `each' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:95:in `create_child' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/chef_fs_data_store.rb:469:in `get_dir' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/chef_fs_data_store.rb:456:in `with_dir' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/chef_fs_data_store.rb:123:in `create' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/data_store/v1_to_v2_adapter.rb:34:in `block in create' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/data_store/v1_to_v2_adapter.rb:113:in `fix_exceptions' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/data_store/v1_to_v2_adapter.rb:33:in `create' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/rest_base.rb:150:in `create_data' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/endpoints/rest_list_endpoint.rb:31:in `post' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/rest_base.rb:30:in `call' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/rest_router.rb:24:in `call' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/server.rb:589:in `block in app' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/server.rb:305:in `call' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/server.rb:305:in `handle_socketless_request' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/socketless_server_map.rb:87:in `request' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/socketless_server_map.rb:33:in `request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http/socketless_chef_zero_client.rb:153:in `request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:266:in `block in send_http_request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:298:in `block in retrying_http_errors' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:296:in `loop' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:296:in `retrying_http_errors' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:260:in `send_http_request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:143:in `request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:126:in `post' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/node.rb:545:in `create' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/node.rb:506:in `rescue in find_or_create' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/node.rb:502:in `find_or_create' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:106:in `load_node' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/client.rb:443:in `load_node' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/client.rb:255:in `run' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:270:in `block in fork_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:258:in `fork' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:258:in `fork_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:224:in `block in run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:39:in `with_server_connectivity' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:212:in `run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:402:in `block in interval_run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `loop' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `interval_run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `run_application' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run' 
==> myboxname: /opt/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>' 
==> myboxname: /usr/bin/chef-client:55:in `load' 
==> myboxname: /usr/bin/chef-client:55:in `<main>' 
==> myboxname: [2015-08-26T06:26:25+00:00] INFO: HTTP Request Returned 500 Internal Server Error: error 
==> myboxname: ================================================================================ 
==> myboxname: Chef encountered an error attempting to load the node data for "vagrant-ubuntu-trusty-64" 
==> myboxname: ================================================================================ 
==> myboxname: Unknown Server Error: 
==> myboxname: --------------------- 
==> myboxname: The server had a fatal error attempting to load the node data. 
==> myboxname: Server Response: 
==> myboxname: ---------------- 
==> myboxname: Exception raised! #<Errno::ENOENT: No such file or directory @ dir_s_mkdir - /tmp/vagrant-chef/cookbooks/nodes> 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:97:in `mkdir' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:97:in `block in create_child' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:95:in `each' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb:95:in `create_child' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/chef_fs_data_store.rb:469:in `get_dir' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/chef_fs_data_store.rb:456:in `with_dir' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/chef_fs/chef_fs_data_store.rb:123:in `create' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/data_store/v1_to_v2_adapter.rb:34:in `block in create' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/data_store/v1_to_v2_adapter.rb:113:in `fix_exceptions' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/data_store/v1_to_v2_adapter.rb:33:in `create' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/rest_base.rb:150:in `create_data' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/endpoints/rest_list_endpoint.rb:31:in `post' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/rest_base.rb:30:in `call' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/rest_router.rb:24:in `call' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/server.rb:589:in `block in app' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/server.rb:305:in `call' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/server.rb:305:in `handle_socketless_request' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/socketless_server_map.rb:87:in `request' 
==> myboxname: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.2.3/lib/chef_zero/socketless_server_map.rb:33:in `request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http/socketless_chef_zero_client.rb:153:in `request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:266:in `block in send_http_request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:298:in `block in retrying_http_errors' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:296:in `loop' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:296:in `retrying_http_errors' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:260:in `send_http_request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:143:in `request' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/http.rb:126:in `post' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/node.rb:545:in `create' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/node.rb:506:in `rescue in find_or_create' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/node.rb:502:in `find_or_create' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:106:in `load_node' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/client.rb:443:in `load_node' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/client.rb:255:in `run' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:270:in `block in fork_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:258:in `fork' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:258:in `fork_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:224:in `block in run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:39:in `with_server_connectivity' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:212:in `run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:402:in `block in interval_run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `loop' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `interval_run_chef_client' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `run_application' 
==> myboxname: /opt/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run' 
==> myboxname: /opt/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>' 
==> myboxname: /usr/bin/chef-client:55:in `load' 
==> myboxname: /usr/bin/chef-client:55:in `<main>' 

И затем сразу же после этого, я бегу vagrant provision myboxname (я» ve суммированные журналы)

$ vagrant provision myboxname 
==> myboxname: Running provisioner: chef_zero... 
==> myboxname: Detected Chef (latest) is already installed 
Generating chef JSON and uploading... 
==> myboxname: Running chef-client (local-mode)... 
==> myboxname: [2015-08-24T11:13:02+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/vagrant-chef/8d6a2619e17bfa48a2eba11cea21e6c6, /tmp/vagrant-chef/cookbooks 
==> myboxname: One version per cookbook 
==> myboxname: [2015-08-24T11:13:02+00:00] INFO: Forking chef instance to converge... 
==> myboxname: Starting Chef Client, version 12.4.1 
==> myboxname: [2015-08-24T11:13:02+00:00] INFO: *** Chef 12.4.1 *** 
==> myboxname: [2015-08-24T11:13:02+00:00] INFO: Chef-client pid: 3457 
==> myboxname: [2015-08-24T11:13:03+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/vagrant-ubuntu-trusty-64 
==> myboxname: [2015-08-24T11:13:03+00:00] INFO: Setting the run_list to ["recipe[mycookbook::default]"] from CLI options 
==> myboxname: [2015-08-24T11:13:03+00:00] INFO: Run List is [recipe[mycookbook::default]] 
==> myboxname: [2015-08-24T11:13:03+00:00] INFO: Run List expands to [mycookbook::default] 
==> myboxname: [2015-08-24T11:13:03+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-64 
==> myboxname: [2015-08-24T11:13:03+00:00] INFO: Running start handlers 
==> myboxname: [2015-08-24T11:13:03+00:00] INFO: Start handlers complete. 
==> myboxname: resolving cookbooks for run list: ["mycookbook::default"] 
==> myboxname: [2015-08-24T11:13:12+00:00] INFO: Loading cookbooks [[email protected]] 
==> myboxname: Synchronizing Cookbooks: 
==> myboxname: [2015-08-24T11:13:20+00:00] INFO: Storing updated cookbooks/mycookbook/README.md in the cache. 
==> myboxname: [2015-08-24T11:13:20+00:00] INFO: Storing updated cookbooks/mycookbook/recipes/default.rb in the cache. 
==> myboxname: [2015-08-24T11:13:20+00:00] INFO: Storing updated cookbooks/mycookbook/CHANGELOG.md in the cache. 
<more INFO storing messages> 
==> myboxname: Compiling Cookbooks... 
==> myboxname: Recipe: mycookbook::default 
<compile stuff> 
==> myboxname: Converging X resources 
<converge stuff> 
<successful chef run> 
+0

Вы можете поручить повару работать в режиме регистрации отладки, чтобы получить более подробную информацию о том, что делается под капотом, добавив a 'machine.chef_zero.log_level =" debug "' в вашем бродячем файле [больше в этом документе] (http://docs.vagrantup.com/v2/provisioning/chef_common.html) – Tensibai

+0

И я не понимаю, как ваши команда vagrant provision может знать, какой список запуска предоставить вашему узлу, поскольку в вашем бродячем файле нет 'обеспечения'блока, вы лишали вещи из вашего бродячего файла во время публикации здесь? Я не могу найти свойство 'enabled' или' cookbooks' для [chef_zero] (https://docs.vagrantup.com/v2/provisioning/chef_zero.html) в бродячей документации. – Tensibai

+0

Вы правы @ Tensibai Я вырезал много материала, чтобы дать соответствующую информацию, но оставил блок обеспечения. Добавили его сейчас. – Brett

ответ

1

Не окончательный ответ, поскольку я по-прежнему не уверен в некоторых моментах.

Цитируя документ об окружающей среде (курсив мой)

environments_path (строка) - Путь, где определение среды расположены . По умолчанию не задана папка окружения.

environment (строка) - Окружающая среда, в которой вы хотите, чтобы шеф-повар работал как часть. Для этого требуется Chef 11.6.0 или новее, и установлено значение environment_path.

и угадывание от фактического файла, который я написал бы vagrantfile так:

Vagrant.configure("2") do |config| 
    # config.chef_zero.enabled = true # I see no use of this, sounds not an available property for chef_zero provider 
    # I'm unsure this works, I would move them in the provision block. 
    config.chef_zero.environments_path = "./environments/" # Define where the environments files are, not the file itself 
    config.chef_zero.environment = "_default" # the default env (should match the name attribute in the _default.json file IIRC. 
    config.chef_zero.data_bags_path = "./data_bags/" # added _path to the property name 
    config.chef_zero.roles_path = "./roles/" # same as above 

    config.vm.define "myboxname" do |machine| 
    machine.vm.provider "virtualbox" do |vbox| 
     vbox.name = "myboxname" 
    end 
    machine.vm.provision :chef_zero do |chef| 
     # Removed the data_bags_path as it's already defined config wise, but could be overridden here for a machine. 
     chef.log_level = "debug" # moved into the provision block, I can't see how it could work on the machine level (and your log seems to confirm this as there's no debug entry in the log) 
     chef.cookbooks_path = "./cookbooks/" # don't give the path to the cookbook, just give the path where the cookbook is 
     chef.run_list = ['recipe[mycookbook::default]'] 
    end 
    end 
end 
2

Это, как представляется, связано с бродяга bug.

Обходной, который работает для меня, чтобы поместить эту строку выше шеф Provisioner в Vagrantfile:

config.vm.provision :shell, inline: 'mkdir -p /tmp/vagrant-chef/cookbooks/nodes' 
+0

Спасибо @phs, еще не проверили, попробуем и отчитаемся здесь. – Brett

+0

работает для меня, спасибо –