From https://www.vagrantup.com/docs/provisioning/chef_solo.html and http://berkshelf.com/, I'm trying to add apt and apache2 recipes.
My settings :
My different steps:
1) Set up vagrant plug-ins:
Installed versions:
$ vagrant plugin list
vagrant-berkshelf (4.1.0)
vagrant-hostmanager (1.8.2)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.5, system)
2) Set up Chef dk 0.15.15 on the host (Necessary to start a vagrant VM with the Berkshelf plugin)
3) Vagrantfile file config
config.vm.network "private_network", ip: "192.168.33.10"
config.omnibus.chef_version = :latest
config.berkshelf.enabled = true
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "apt"
chef.add_recipe "apache2"
end
4) Create manually the Berksfile file (in the same folder as Vagrantfile)
source "https://supermarket.chef.io"
cookbook "apt"
cookbook "apache2"
After doing these settings, I can do the vagrant up to start the machine.
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Using apache2 (3.2.2)
==> default: Using apt (4.0.1)
==> default: Using compat_resource (12.10.6)
==> default: Vendoring apache2 (3.2.2) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apache2
==> default: Vendoring apt (4.0.1) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apt
==> default: Vendoring compat_resource (12.10.6) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/compat_resource
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 5.0
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => D:/Vagrant VMs Files/Linux/Ubuntu Standard/v12.04 LTS Precise/Hashicorp-Precise64 - Template (TUTO)
default: /tmp/vagrant-chef/83b8a9c0ce916541f1e94cb0043abcfa/cookbooks => C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
And then doing a vagrant provision
vagrant provision
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Using apache2 (3.2.2)
==> default: Using apt (4.0.1)
==> default: Using compat_resource (12.10.6)
==> default: Vendoring apache2 (3.2.2) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apache2
==> default: Vendoring apt (4.0.1) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apt
==> default: Vendoring compat_resource (12.10.6) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/compat_resource
==> default: Chef 12.11.18 Omnibus package is already installed.
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
==> default: Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2016-06-30T07:06:10+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/vagrant-chef/83b8a9c0ce916541f1e94cb0043abcfa
==> default: One version per cookbook
==> default: [2016-06-30T07:06:10+00:00] INFO: Forking chef instance to converge...
==> default: Starting Chef Client, version 12.11.18
==> default: [2016-06-30T07:06:10+00:00] INFO: *** Chef 12.11.18 ***
==> default: [2016-06-30T07:06:10+00:00] INFO: Platform: x86_64-linux
==> default: [2016-06-30T07:06:10+00:00] INFO: Chef-client pid: 1377
==> default: [2016-06-30T07:06:13+00:00] INFO: GET /organizations/chef/nodes/vagrant-084b5399
==> default: [2016-06-30T07:06:13+00:00] INFO: #<ChefZero::RestErrorResponse: 404: Object not found: chefzero://localhost:8889/nodes/vagrant-084b5399>
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:91:in `rescue in get_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:83:in `get_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/endpoints/rest_object_endpoint.rb:18:in `get'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:62:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_router.rb:24:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:664:in `block in app'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `handle_socketless_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:87:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:33:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http/socketless_chef_zero_client.rb:154:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:305:in `block in send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:336:in `block in retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:299:in `send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:144:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:111:in `get'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:604:in `load'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:588:in `find_or_create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/policy_builder/dynamic.rb:72:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:467:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:269:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:286:in `block in fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:239:in `block in run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/local_mode.rb:44:in `with_server_connectivity'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:227:in `run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:426:in `run_application'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:59:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/solo.rb:217:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:52:in `load'
==> default: /usr/bin/chef-solo:52:in `<main>'
==> default: [2016-06-30T07:06:13+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/vagrant-084b5399
==> default: [2016-06-30T07:06:13+00:00] INFO: POST /organizations/chef/nodes
==> default: --- POST BODY ---
==> default: {"name":"vagrant-084b5399","chef_environment":"_default","json_class":"Chef::Node","automatic":{},"normal":{},"chef_type":"node","default":{},"override":{},"run_list":[]}
==> default: --- END POST BODY ---
==> default: [2016-06-30T07:06:13+00:00] INFO: #<ChefZero::RestErrorResponse: 404: Parent not found: chefzero://localhost:8889/nodes>
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:187:in `rescue in create_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:181:in `create_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/endpoints/rest_list_endpoint.rb:31:in `post'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/endpoints/nodes_endpoint.rb:24:in `post'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:62:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_router.rb:24:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:664:in `block in app'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `handle_socketless_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:87:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:33:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http/socketless_chef_zero_client.rb:154:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:305:in `block in send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:336:in `block in retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:299:in `send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:144:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:127:in `post'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:639:in `create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:592:in `rescue in find_or_create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:588:in `find_or_create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/policy_builder/dynamic.rb:72:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:467:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:269:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:286:in `block in fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:239:in `block in run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/local_mode.rb:44:in `with_server_connectivity'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:227:in `run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:426:in `run_application'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:59:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/solo.rb:217:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:52:in `load'
==> default: /usr/bin/chef-solo:52:in `<main>'
==> default: [2016-06-30T07:06:13+00:00] INFO: HTTP Request Returned 404 Not Found: Parent not found: chefzero://localhost:8889/nodes
==> default: ================================================================================
==> default: Chef encountered an error attempting to load the node data for "vagrant-084b5399"
==> default: ================================================================================
==> default:
==> default: Resource Not Found:
==> default: -------------------
==> default: The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
==> default: Relevant Config Settings:
==> default: -------------------------
==> default: chef_server_url "chefzero://localhost:8889"
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default: Running handlers:
==> default: [2016-06-30T07:06:13+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2016-06-30T07:06:13+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 0 resources updated in 02 seconds
==> default: [2016-06-30T07:06:13+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2016-06-30T07:06:13+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2016-06-30T07:06:13+00:00] ERROR: 404 "Not Found"
==> default: [2016-06-30T07:06:14+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
As you can see, I have some errors (Chef encountered an error attempting to load the node data for "vagrant-084b5399"), please see the chef-stacktrace.out file content below
Generated at 2016-06-30 07:06:13 +0000
Net::HTTPServerException: 404 "Not Found"
/opt/chef/embedded/lib/ruby/2.1.0/net/http/response.rb:119:in `error!'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:146:in `request'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:127:in `post'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:639:in `create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:592:in `rescue in find_or_create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:588:in `find_or_create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/policy_builder/dynamic.rb:72:in `load_node'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:467:in `load_node'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:269:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:286:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:239:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:227:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:426:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/solo.rb:217:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:52:in `load'
/usr/bin/chef-solo:52:in `<main>'
I have verified, apache2 is not installed on the VM.
I don't know what these errors mean, is there a mistake somewhere?
You need to upgrade your Vagrant, the latest is 1.8.4. We made some changes to how chef-solo works internally that Vagrant had to adjust to.