My vagrant failed when provisioning with template.
template "/var/.s3cfg" do
source "s3cfg.erb"
owner "root"
group "root"
mode "0644"
end
in that cookbook directory, file templates/default/s3cfg.erb exists.
But strangely it's work successfully on opswork amazon, so it might be vagrant, vagrant-cachier, vagrant-berkshelf, berkshelf, or chef error.
Any idea how to check?
My environment:
$: vagrant -v
Vagrant 1.6.5
$: vagrant plugin list
vagrant-berkshelf (3.0.1)
vagrant-cachier (0.9.0)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.1, system)
$: chef -v
Chef Development Kit Version: 0.2.2
$: berks -v
3.1.5
vagrant box is ubuntu-precise 12.04
Apparently the cause is because chef default location of provisioning path located at /tmp/vagrant-chef. In the middle of the chef execution, somehow the /tmp/ folder cleaned. Hence the missing file.
By changing the location of chef.provisioning_path to other folder than /tmp/, it worked normally.
Related
I'm trying to run a VM with Vagrant on Windows 10. Vagrant installed fine. I tried to run vagrant up --provision and always got
The plugins failed to load properly. The error message given is
shown below.
cannot load such file -- rack
This seems like a Ruby problem, so I installed Ruby and Rack. But Ruby is only recognized on my home directory, not the directory of the application.
Could be that your local Ruby installation is missing Rack:
gem install rack
I want to spin up a Vagrant box and provision a LAMP stack using chef-solo and berkshelf. Here's the steps I take:
berks cookbook my_project
Then in Berksfile:
site :opscode
cookbook 'wordpress', '~> 3.0.0'
cookbook 'apache2', '~> 3.2.2'
cookbook 'mysql', '~> 8.2.0'
cookbook 'php', '~> 2.2.0'
Then berks vendor cookbooks
The Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
Vagrant.require_version '>= 1.5.0'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.hostname = 'unify-config-berkshelf'
if Vagrant.has_plugin?("vagrant-omnibus")
config.omnibus.chef_version = 'latest'
end
config.vm.box = 'bento/ubuntu-14.04'
config.vm.network :private_network, type: 'dhcp'
config.vm.provision :chef_solo do |chef|
chef.json = {
mysql: {
server_root_password: 'rootpass',
server_debian_password: 'debpass',
server_repl_password: 'replpass'
}
}
chef.run_list = [
"recipe[apache2]",
"recipe[apache2::mod_php5]",
"recipe[mysql::client]",
"recipe[mysql::server]",
"recipe[php]",
"recipe[php::module_mysql]"
]
end
end
Then I try to bring the box up with vagrant up. This is the error I get.
The following berks command failed to execute:
/Users/stoebelj/.rbenv/shims/berks --version --format json
The stdout and stderr are shown below:
stdout:
stderr: Ignoring ffi-1.9.14 because its extensions are not built. Try: gem pristine ffi --version 1.9.14
Ignoring nokogiri-1.6.7.1 because its extensions are not built. Try: gem pristine nokogiri --version 1.6.7.1
Ignoring unf_ext-0.0.7.2 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.2
Ignoring wdm-0.1.1 because its extensions are not built. Try: gem pristine wdm --version 0.1.1
/Users/stoebelj/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'berkshelf' (>= 0.a) among 47 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/opt/vagrant/embedded/gems', execute `gem env` for more information
from /Users/stoebelj/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /Users/stoebelj/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /Users/stoebelj/.rbenv/versions/2.3.1/bin/berks:22:in `<main>'
It appears that you are not using the ChefDK. Please note that Vagrant Berkshelf
works best when used with the ChefDK, and other installation methods are not
officially supported.
Please download and install the latest version of the ChefDK from:
https://downloads.chef.io/chef-dk
and follow the installation instructions. Do not forget to add the ChefDK to
your PATH.
I installed ChefDK from the URL given and /usr/local/bin/chef is in my PATH
What am I misunderstanding?
Update
A question below suggested I remove berkshelf from my rbenv, which did indeed get rid of the below error. Now I have a different error:
The Berkshelf version at "/usr/local/bin/berks" is invalid.
Vagrant Berkshelf requires >= 4.0, but the current version is .
Please download and install the latest version of the ChefDK from:
https://downloads.chef.io/chef-dk
and follow the installation instructions. Do not forget to add the ChefDK to
your PATH.
For context, I checked this which suggested I update my plugin. This did not work. I also tried removing the plugin and installing version 4.1 which also did not work.
And for context:
$ vagrant plugin list
vagrant-berkshelf (5.1.1)
vagrant-omnibus (1.5.0)
vagrant-share (1.1.6, system)
$ which berks
/usr/local/bin/berks
berks seems to work fine on its own but produces a warning I don't understand:
$ berks
W, [2017-02-13T13:46:00.590751 #3199] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591227 #3199] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591452 #3199] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591672 #3199] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.629581 #3199] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.629737 #3199] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Resolving cookbook dependencies...
Fetching 'unify_config' from source at .
Using apache2 (3.2.2)
Using build-essential (7.0.3)
Using compat_resource (12.16.3)
Using iis (5.0.5)
Using mingw (1.2.5)
Using mysql (8.2.0)
Using ohai (4.2.3)
Using php (2.2.0)
Using seven_zip (2.0.2)
Using unify_config (0.1.0) from source at .
Using windows (2.1.1)
Using xml (3.1.1)
Using yum-epel (2.1.1)
As shown in the command it is trying to run, the issue isn't the chef executable, it's berks. Remove the copy of that you installed via gems and makes sure the copy from ChefDK is working.
Ran into this issue couple days ago as well. Rolling back the version of ChefDK helped for me:
ChefDK 1.1.16
Coworker of mine was the one the dug up the reasoning, stating:
"vagrant uses berks -version --format json or something of the like to get the version of berks but running that command leads to some warning logs output by some dependency berks uses
which is why the version is blank"
I've followed the instructions at: http://berkshelf.com/ after installing the latest ChefDK (from here: http://downloads.getchef.com/chef-dk/mac/#/). When I do "vagrant up", I get the error:
Vagrant:
* Unknown configuration section 'omnibus'.
Various posts (e.g. Vagrant Install chef-client on top of base image) have suggested this means that the vagrant-omnibus plugin is not installed. In my case, I have installed it. "vagrant plugin list" displays:
vagrant-berkshelf (2.0.1)
- Version Constraint: 2.0.1
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.1, system)
Any suggestions as to how I can get this example cookbook to run on a new VM instance launched with "vagrant up"?
It turns out the issue for me was that while ~/.vagrant.d/plugins.json included the vagrant-omnibus plugin, the ~/.vagrant.d/gems/gems and ~/.vagrant.d/gems/specifications directories did not contain the appropriate GEM or gemspec files. Not sure how this happened, but I suspect it was due to accidentally typing ^C in the middle of execution of the vagrant plugin install command and then reexecuting that command.
It would appear vagrant plugin install does not do appropriate ^C handling and that it writes the contents of plugins.json before it has stored the gem and gemspec.
Subsequent vagrant plugin install commands don't fix the problem. Manually editing plugins.json to remove the plugin and then reexecuting the vagrant plugin install vagrant-omnibus command fixed the issue.
I personally went inside the vagrant file using VI editor
and commented out the line that has omni bus script
and then run "
vagrant status" and then "vagrant up"
1.vi Vagrant
2.?omnibus
3."insert" I omnibus
4.insert # to comment out the line
5. wq! to come out of vi editor
** this issue can also be related with the type of OS one is using ,i am using a mac
Ok, I'm trying to update chef-client with vagrant omnibus and proxyconf. I figured it would pull the proxy from the proxyconf, but it doesn't look that way. Here is my plugin list:
vagrant plugin list
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
- Version Constraint: 1.4.1
vagrant-proxyconf (1.3.2)
- Version Constraint: 1.3.2
vagrant-share (1.1.0, system)
and my Vagrant file:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.omnibus.chef_version = :latest
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "my proxy"
config.proxy.https = "my proxy"
end
When i run it with vagrant up, the machine does not have an updated chef-client. I tried using the recipe[omnibus_updater] in my run list it still fails because another recipe is failing with a compile failure (because of the older version of chef-client, what a pain in the butt). Any ideas? Other than creating a new virtual box?
Update:
Running in debug mode doesn't show any errors using :latest. Updating to 11.12.8 gives the below error
vagrant-omnibus:
* '11.12.8' is not a valid version of Chef.
Logging into the vm shows $HTTP_PROXY and $HTTPS_PROXY set properly. Running the commands on the built vm works:
chef-client -v
Chef: 10.14.2
sudo gem update chef
chef-client -v
Chef: 11.12.8
Thing 1:
:latest does not error out when it fails to grab the artifact. Switching to a named version starts to fail to find the artifact which leads me to believe that it isn't getting through the proxy.
Thing 2:
I think this is a problem with omnibus in windows. I've found this pull that may fix it? https://github.com/schisamo/vagrant-omnibus/pull/89. I think this plug-in isn't using the settings set by poxy-conf.
CURRENTLY USING THIS WORKAROUND:
Set you http proxy in the windows cmd line
SET HTTP_PROXY=http://username:password#proxy:port
To use digital ocean as a vagrant provider, I followed instruction here.
But I get this error.
$ vagrant up --provider=degital_ocean
The provider 'degital_ocean' could not be found, but was requested to
back the machine 'default'. Please use a provider that exists.
This is a result of $ vagrant plugin list
sahara (0.0.16)
vagrant-berkshelf (1.3.7)
vagrant-digitalocean (0.5.3)
vagrant-hostsupdater (0.0.11)
vagrant-omnibus (1.2.1)
What have I missed?
You misspelled "digital". $ vagrant up --provider=digital_ocean