Chef-zero provision: unlocated cookbook - vagrant

I'm getting this message:
==> default: ================================================================================
==> default: Recipe Compile Error
==> default: ================================================================================
==> default:
==> default: Chef::Exceptions::RecipeNotFound
==> default: --------------------------------
==> default: could not find recipe default for cookbook olingo
==> default: System Info:
==> default: ------------
==> default: chef_version=13.6.4
==> default: platform=centos
==> default: platform_version=7.4.1708
==> default: ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
==> default: program_name=chef-client worker: ppid=4729;start=20:31:47;
==> default: executable=/opt/chef/bin/chef-client
As you can see, chef is not able to find olingo cookbook.
My vagrant chef-zero provision section is:
config.vm.provision "chef_zero" do |chef|
chef.cookbooks_path = "berks-cookbooks"
chef.data_bags_path = "data_bags"
chef.nodes_path = "nodes"
chef.roles_path = "roles"
chef.add_recipe "olingo" <<<<1>>>>
end
As you can see at <<<<1>>>>, I've specified that chef installs olingo cookbook. As you can see, I'm using chef-zero as well.
In order to download all cookbook dependencies, I'm using berkshelf tool. So I've created a Berksfile:
source 'https://supermarket.chef.io'
metadata
and metadata.rb:
name 'olingo' <<<2>>>
maintainer 'The Authors'
maintainer_email 'you#example.com'
license 'all_rights'
description 'Installs/Configures webapi'
long_description 'Installs/Configures webapi'
version '0.1.0'
depends 'java_se', '~> 8.141.0'
depends 'wildfly', '~> 0.4.0'
So, then I perform berks vendor and a berks-cookbooks folder is created filled with all olingo dependencies, but no olingo cookbook is located there.
So, it seems olingo cookbook is not available when chef_client tries to install olingo cookbook.
Any ideas?

Related

Chef solo with berkshelf: cookbook not resolved

I've created this Vagrantfile's provioner section:
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "wildfly"
end
I'm getting this error:
==> default: Error Resolving Cookbooks for Run List:
==> default:
==> default: Missing Cookbooks:
==> default: ------------------
==> default: No such cookbook: wildfly
So, I've created a Berksfile and a metadata.rb files:
Berksfile:
source 'https://supermarket.chef.io'
metadata
metadata.rb:
name 'webapi'
maintainer 'The Authors'
maintainer_email 'you#example.com'
license 'all_rights'
description 'Installs/Configures webapi'
long_description 'Installs/Configures webapi'
version '0.1.0'
depends 'java_se', '~> 9.0.1'
depends 'wildfly', '~> 0.4.0'
So, then I've performed berks install command. The first issue I've detected is that I don't quite detect where berks has placed cookbooks. It seems that it works right, nevertheless, I don't find where cookbooks dependencies are located, I mean, a .\cookbooks folder is not created after performing berks install command.
Resolving cookbook dependencies...
Fetching 'olingo' from source at .
Fetching cookbook index from https://supermarket.chef.io...
Using apt (6.1.4)
Using homebrew (4.2.0)
Using java (1.50.0)
Using java_se (9.0.1)
Using ohai (5.2.0)
Using olingo (0.1.0) from source at .
Using wildfly (0.4.0)
Using yum (5.1.0)
Using windows (3.4.0)
Regardless of that, I've performed vagrant provision again, and wildfly cookbook is not resolved:
The cookbook path 'D:/projects/swiller/querydsl/olingo/infrastructure/cookbooks' doesn't exist. Ignoring...
Running provisioner: chef_solo...
==> default: Error Resolving Cookbooks for Run List:
==> default:
==> default: Missing Cookbooks:
==> default: ------------------
==> default: No such cookbook: wildfly
You either need to use the vagrant-berkshelf plugin, or use the berks vendor command to write all the cookbooks to a folder and then point Vagrant at that (which is what the plugin does internally). berks install only downloads them to your workstation, it doesn't put the cookbooks in a place/format that anything other than Berkshelf understands.

Syntax error on a Chef official recipe, provisioning Vagrant

I'm having a syntax error on an official recipe. When I tried to run this recipe from inside a vagrant box, it worked fine. I used:
chef-client --local-mode --runlist [...]
Now I'm trying to provision the box with chef-solo, as chef-client requires a server and keys. It should be equivalent.
This is my Vagrantfile, where I have two machines, each provisioned by some chef recipes. I also set ssh to X mode, DNS redirection for name resolving, the memory assigned to each machine, and the shared folder.
The error appears if I add to the runlist recipe1, recipe2, or even without any recipy in runlist.
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
# Needs vagrant 1.7.2 or newer
# chef.install = true
# chef.version = "latest"
# ---- BEGIN MOST RELEVANT PART ----
config.vm.define "mybox" do |a|
a.vm.network "private_network", ip: "192.168.33.12"
config.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "myproject-cookbook/cookbooks"
#chef.add_recipe "myproject::recipe1"
#chef.add_recipe "myproject::recipe2"
#chef.add_recipe "myproject::recipe3"
end
end
# ---- END MOST RELEVANT PART ----
config.vm.define "myotherbox" do |c|
c.vm.network "private_network", ip: "192.168.33.11"
config.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "myproject-cookbook/cookbooks"
chef.add_recipe "myproject::recipe4"
end
end
config.ssh.forward_x11 = true
config.vm.provider :virtualbox do |vb|
# DNS queries to the host, which becomes a DNS Proxy
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
# Lease more RAM to the guest
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
config.vm.synced_folder "../shared", "/home/vagrant/public"
end
The actual error comes from an official cookbook, windows, which I don't know why chef runs it if I haven't specified a single recipe to run.
$ vagrant provision
==> mybox: Running provisioner: chef_solo...
Generating chef JSON and uploading...
==> mybox: Warning: Chef run list is empty. This may not be what you want.
==> mybox: Running chef-solo...
==> mybox: stdin: is not a tty
==> mybox: [2015-03-04T11:08:09+00:00] INFO: *** Chef 10.14.2 ***
==> mybox: [2015-03-04T11:08:11+00:00] INFO: Run List is []
==> mybox: [2015-03-04T11:08:11+00:00] INFO: Run List expands to []
==> mybox: [2015-03-04T11:08:11+00:00] INFO: Starting Chef Run for precise64
==> mybox: [2015-03-04T11:08:11+00:00] INFO: Running start handlers
==> mybox: [2015-03-04T11:08:11+00:00] INFO: Start handlers complete.
==> mybox:
==> mybox: ================================================================================
==> mybox: Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/windows/libraries/windows_package.rb
==> mybox: ================================================================================
==> mybox:
==> mybox: SyntaxError
==> mybox: -----------
==> mybox: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/windows/libraries/windows_package.rb:239: syntax error, unexpected ':', expecting kEND
==> mybox: provides :windows_package, os: "windows"
==> mybox: ^
==> mybox: Cookbook Trace:
==> mybox: ---------------
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:140:in `load'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:140:in `load_libraries'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:230:in `call'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:230:in `foreach_cookbook_load_segment'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:229:in `each'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:229:in `foreach_cookbook_load_segment'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:227:in `each'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:227:in `foreach_cookbook_load_segment'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:137:in `load_libraries'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:62:in `load'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:198:in `setup_run_context'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:418:in `do_run'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:176:in `run'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:230:in `run_application'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `loop'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `run_application'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application.rb:70:in `run'
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/chef-solo:25
==> mybox: /opt/vagrant_ruby/bin/chef-solo:19:in `load'
==> mybox: /opt/vagrant_ruby/bin/chef-solo:19
==> mybox:
==> mybox: Relevant File Content:
==> mybox: ----------------------
==> mybox: /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:
==> mybox:
==> mybox: 1: #
==> mybox: 2: # Author:: Adam Jacob (<adam#opscode.com>)
==> mybox: 3: # Author:: Christopher Walters (<cw#opscode.com>)
==> mybox: 4: # Author:: Tim Hinderliter (<tim#opscode.com>)
==> mybox: 5: # Copyright:: Copyright (c) 2008-2010 Opscode, Inc.
==> mybox: 6: # License:: Apache License, Version 2.0
==> mybox: 7: #
==> mybox: 8: # Licensed under the Apache License, Version 2.0 (the "License");
==> mybox: 9: # you may not use this file except in compliance with the License.
==> mybox:
==> mybox: [2015-03-04T11:08:11+00:00] ERROR: Running exception handlers
==> mybox: [2015-03-04T11:08:11+00:00] ERROR: Exception handlers complete
==> mybox: [2015-03-04T11:08:11+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> mybox: [2015-03-04T11:08:11+00:00] FATAL: SyntaxError: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/windows/libraries/windows_package.rb:239: syntax error, unexpected ':', expecting kEND
==> mybox: provides :windows_package, os: "windows"
==> mybox: ^
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
It's relevant to say that I haven't edited this recipe, that it works fine with chef-client executing it manually instead of from vagrant, and most important, that the exact version of ruby that should be executing the recipe says there is no syntax:
$ /opt/chef/embedded/bin/ruby -c myproject-cookbook/cookbooks/windows/libraries/windows_package.rb
Syntax OK
You can check the recipe failing in github
The cookbooks in the cookbooks folder are:
7-zip
ark
chef_handler
java
maven
myproject
windows
Actual questions:
Why is this "windows_package" recipe run?
Why chef complains about a Syntax error and ruby by itself doesn't?
EDIT (I have a hardly any privilege):
Yes, chef is strangely at version 10.14.2 in guest "mybox":
vagrant#precise64:~$ chef-solo -v
Chef: 10.14.2
Instead, chef-client in host is at the version installed by the omnibus installer...
user#host$ chef-solo -v
Chef: 12.1.0
I thought that host's chef was replicated to the guest and then run inside guest, I will recheck provisioning and try to make it install the proper version.
Thanks!
EDIT2:
It was actually the chef version. It looks like no chef needs to be installed on the host beforehand; instead, vagrant installs it by itself on guest, choosing the version it likes.
Until vagrant version 1.7.2 one needed to install vagrant-omnibus plugin in order to choose the version to install. See how to do it.
Starting from 1.7.2, one can do it without the need of any plugin, using "install" and "version" methods. The doc here.
Source: Mazinlabs blog (in japanese)
I'm pretty sure this has to do with the chef version installed on the box:
==> mybox: [2015-03-04T11:08:09+00:00] INFO: *** Chef 10.14.2 ***
I can't be sure but I bet you're using a different chef version when trying from ssh. Anyway 10.14.2 is pretty old and you'll hit errors with recent cookbooks.
IIRC there's a vagrant plugin to install/upadte chef (vagrant-omnibus ?)

Why can't I install a vagrant environment with chef? certificate verify failed (OpenSSL::SSL::SSLError)

My environment:
OS: Mac 10.10.1
rbenv: rbenv 0.4.0-129-g7e0e85b
Ruby: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
My Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "precise32"
# Configurate the virtual machine to use 2GB of RAM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# Forward the Rails server default port to the host
config.vm.network :forwarded_port, guest: 3000, host: 3000
# Use Chef Solo to provision our virtual machine
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "nodejs"
chef.add_recipe "ruby_build"
chef.add_recipe "rbenv::user"
chef.add_recipe "rbenv::vagrant"
chef.add_recipe "vim"
chef.add_recipe "mysql::server"
chef.add_recipe "mysql::client"
# Install Ruby 2.1.2 and Bundler
# Set an empty root password for MySQL to make things simple
chef.json = {
rbenv: {
user_installs: [{
user: 'vagrant',
rubies: ["2.1.2"],
global: "2.1.2",
gems: {
"2.1.2" => [
{ name: "bundler" }
]
}
}]
},
mysql: {
server_root_password: ''
}
}
end
end
My Cheffile:
site "http://community.opscode.com/api/v1"
cookbook 'apt'
cookbook 'build-essential'
cookbook 'mysql'
cookbook 'ruby_build'
cookbook 'nodejs', git: 'https://github.com/mdxp/nodejs-cookbook'
cookbook 'rbenv', git: 'https://github.com/fnichol/chef-rbenv'
cookbook 'vim'
After I run vagrant up, I got these errors:
➜ MY_RAILS_PROJECT vagrant up
/Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/util/which.rb:32: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Installing Chef cookbooks with Librarian-Chef...
[default] Destroying VM and associated drives...
[default] Running cleanup tasks for 'chef_solo' provisioner...
/Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:800:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:800:in `block in connect'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/timeout.rb:55:in `timeout'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/timeout.rb:100:in `timeout'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:800:in `connect'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:756:in `do_start'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /Users/jingqiangzhang/.vagrant.d/gems/gems/librarian-chef-0.0.4/lib/librarian/chef/source/site.rb:353:in `block in http_get'
I have found this article:
http://railsapps.github.io/openssl-certificate-verify-failed.html
I can confirm my openssl version:
➜ MY_RAILS_PROJECT openssl version
OpenSSL 1.0.1j 15 Oct 2014
I don't know what's the reason.
Change your site to https://supermarket.chef.io/api/v1. If that still fails, you'll need to update your TLS CA data. I'm not sure how Vagrant deals with this, but you can try using certifi if you have a working Python install:
pip install certifi
export SSL_CERT_FILE="$(python -m certifi)"

Unable to run unicorn app server on a vagrant box

I have a vagrant box on which RVM is already installed with ruby 2.0.0-p247. I have packaged the vagrant box and using that box as a base box.
Now I am trying to git clone a github private repo and start the unicorn app server, chef is errors out,here is the output of the error
==> default: stdin: is not a tty
==> default: /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find chef (>= 0) amongst [bundler-1.7.7, bundler-unload-1.0.2, executable-hooks-1.3.2, gem-wrappers-1.2.7, rubygems-bundler-1.4.4, rvm-1.11.3.9] (Gem::LoadError)
==> default: from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
==> default: from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
==> default: from /usr/bin/chef-solo:22:in `<main>'
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
I am not able to debug the issue. Its ubuntu 14.04 box. Kindly help me out
Use the vagrant-omnibus plugin to install Chef. This will give Chef its own isolated Ruby environment separate from your RVM setup.

Vagrant with librarian-chef installing ruby via ruby_build & rbenv

over the last few weeks i have had to reinstall my whole working environment a few times and it can take a while so now i have an ambitious idea to use vagrant and librarian-chef to create my working environment so that all i have to do is run a bash script and viola i am in.
so the first time i did this was solo vagrant i went in and did everything and packaged it and it was great for only a while.. the package was 600mb so next idea was to have chef do it all. but i have never worked with chef before so i found librarian-chef basically i librarian-chef init and it makes a cheffile that you can specify cookbooks mine looks like this
site 'http://community.opscode.com/api/v1'
cookbook 'apt'
cookbook 'git'
cookbook 'build-essential'
cookbook 'ruby_build',
git: 'git://github.com/fnichol/chef-ruby_build'
cookbook 'rbenv',
git: 'git://github.com/fnichol/chef-rbenv'
cookbook 'sqlite',
git: 'git://github.com/opscode-cookbooks/sqlite.git'
cookbook 'nodejs',
git: 'http://github.com/mdxp/nodejs-cookbook'
cookbook 'mysql',
git: 'git://github.com/opscode-cookbooks/mysql.git'
cookbook 'redis',
git: 'git://github.com/brianbianco/redisio.git'
cookbook 'zlib',
git: 'git://github.com/opscode-cookbooks/zlib'
cookbook 'wkhtmltopdf',
git: 'git://github.com/firstbanco/chef-wkhtmltopdf.git'
and you tell vagrant and chef to build these when you call vagrent up
in the vagrantfile
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks","site-cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "build-essential"
chef.add_recipe "git"
chef.add_recipe "ruby_build"
chef.add_recipe "rbenv::install"
chef.add_recipe "sqlite"
chef.add_recipe "nodejs"
chef.add_recipe "mysql"
chef.add_recipe "redis"
chef.add_recipe "zlib"
chef.add_recipe "wkhtmltopdf"
end
now i was wondering if i could get ruby_build to install 1.9.3-p290 i found this question which seemed to have the answer but i am getting the following
Running chef-solo...
stdin: is not a tty
[2013-05-23T14:31:18+00:00] INFO: *** Chef 10.14.2 ***
[2013-05-23T14:31:18+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[build-essential]", "recipe[git]", "recipe[ruby_build]", "recipe[rbenv::install]", "recipe[sqlite]", "recipe[nodejs]", "recipe[mysql]", "recipe[redis]", "recipe[zlib]", "recipe[wkhtmltopdf]"] from JSON
[2013-05-23T14:31:18+00:00] INFO: Run List is [recipe[apt], recipe[build-essential], recipe[git], recipe[ruby_build], recipe[rbenv::install], recipe[sqlite], recipe[nodejs], recipe[mysql], recipe[redis], recipe[zlib], recipe[wkhtmltopdf]]
[2013-05-23T14:31:18+00:00] INFO: Run List expands to [apt, build-essential, git, ruby_build, rbenv::install, sqlite, nodejs, mysql, redis, zlib, wkhtmltopdf]
[2013-05-23T14:31:18+00:00] INFO: Starting Chef Run for precise64
[2013-05-23T14:31:18+00:00] INFO: Running start handlers
[2013-05-23T14:31:18+00:00] INFO: Start handlers complete.
================================================================================
Recipe Compile Error
================================================================================
Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe ruby_build for cookbook rbenv
[2013-05-23T14:31:19+00:00] ERROR: Running exception handlers
[2013-05-23T14:31:19+00:00] ERROR: Exception handlers complete
[2013-05-23T14:31:19+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-05-23T14:31:19+00:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe ruby_build for cookbook rbenv
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
how can i get ruby installed as well through ruby build is it possible or is this not possible
Librarian will install your cookbooks locally, but they aren't transferred to the remote vagrant box. You'll need to use the Vagrant Librarian Chef plugin.
See also:
Berkshelf
Vagrant Berkshelf
try adding ruby_build to the run list:
"run_list": [ "ruby_build", "recipe[main]" ]

Resources