I’m trying to get started with Chef and Vagrant and Chef is experiencing a 404 Http error when I launch the vagrant instance, full output is shown below. Does anyone have any idea?
[default] VM already created. Booting if it's not already running...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 3000 => 3000 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] Running provisioner: Vagrant::Provisioners::ChefClient...
[default] Creating folder to hold client key...
[default] Uploading chef client validation key...
[default] Generating chef JSON and uploading...
[default] Running chef-client...
stdin: is not a tty
[Sat, 23 Jun 2012 04:46:51 -0700] INFO: Starting Chef Run
/usr/lib/ruby/1.8/net/http.rb:2101:in `error!'
:
404 "Not Found"
(
Net::HTTPServerException
)
from /usr/lib/ruby/1.8/chef/rest.rb:233:in `run_request'
from /usr/lib/ruby/1.8/chef/rest.rb:95:in `post_rest'
from /usr/lib/ruby/1.8/chef/client.rb:221:in `create_registration'
from /usr/lib/ruby/1.8/chef/client.rb:199:in `register'
from /usr/lib/ruby/1.8/chef/client.rb:73:in `run'
from /usr/lib/ruby/1.8/chef/application/client.rb:186:in `run_application'
from /usr/lib/ruby/1.8/chef/application/client.rb:178:in `loop'
from /usr/lib/ruby/1.8/chef/application/client.rb:178:in `run_application'
from /usr/lib/ruby/1.8/chef/application.rb:57:in `run'
from /usr/bin/chef-client:25
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
chef-client -c /tmp/vagrant-chef-1/client.rb -j /tmp/vagrant-chef-1/dna.json
The contents of my vagrant file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "lucid32-rvm-ruby193"
config.vm.forward_port 3000, 3000
config.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://api.opscode.com/organizations/xxx"
chef.validation_key_path = "xxx-validator.pem"
chef.validation_client_name = "xxx-validator"
end
end
That's the error you should get when you've typed the chef_server_url wrong. For example if you put:
chef.chef_server_url = "https://www.opscode.com/organizations/xxx"
Note the www instead of API, you would get that error. Had there not been a valid server to return a 404 you would get another error (probably name resolution if it's from a typo). Check the /tmp/vagrant-chef-1/client.rb file to verify it has the right URL, and double check your Vagrantfile to be sure you're using the right url.
Related
I'm trying to run a Windows 10 guest on an OSX host.
I've installed the latest versions of Vagrant, VirtualBox. I set up a very basic Vagrantfile as follows:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "Microsoft/EdgeOnWindows10"
config.vm.box_version = "1.0"
end
When I try to start Vagrant by executing "vagrant up", I get the following console output which ends with a neverending series of Authentication failure error messages.
TCR-C02X29QPJHC9:automation salimfadhley$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'Microsoft/EdgeOnWindows10'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'Microsoft/EdgeOnWindows10' version '1.0' is up to date...
==> default: Setting the name of the VM: automation_default_1548152471264_36082
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2200 (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:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
I don't need Edge - I just need Windows and possibly some dot-Net runtimes. I'd like to get started by getting any Windows image up and running.
You probably just need to use the following in your Vagrantfile:
config.vm.communicator = "winrm"
This option is described here, and you can further configure winrm with the settings listed here.
I'm trying to set up Vagrant for web development, on Windows 8.1. I've already hit the problem undefined method “cheffish” for nil:NilClass, so am using Vagrant 1.7.4 with Chef 12.3.0.
I can't solve this error:
ERROR: You must specify at least one cookbook repo path
from:
c:\web\project>vagrant provision
==> default: The cookbook path 'c:/web/project/cookbooks' doesn't exist. Ignoring...
==> default: The cookbook path 'c:/web/project/site-cookbooks' doesn't exist. Ignoring...
==> default: Chef 12.3.0 Omnibus package is already installed.
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2015-07-21T10:08:00+00:00] INFO: Forking chef instance to converge...
==> default: Starting Chef Client, version 12.3.0
==> default: [2015-07-21T10:08:00+00:00] INFO: *** Chef 12.3.0 ***
==> default: [2015-07-21T10:08:00+00:00] INFO: Chef-client pid: 1813
==> default: [2015-07-21T10:08:01+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[nodejs]", "recipe[postgresql]", "recipe[postgresql::ser
ver]", "recipe[postgresql::client]"] from CLI options
==> default: [2015-07-21T10:08:01+00:00] INFO: Run List is [recipe[apt], recipe[nodejs], recipe[postgresql], recipe[postgresql::server], recipe[postgr
esql::client]]
==> default: [2015-07-21T10:08:01+00:00] INFO: Run List expands to [apt, nodejs, postgresql, postgresql::server, postgresql::client]
==> default: [2015-07-21T10:08:01+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-64
==> default: [2015-07-21T10:08:01+00:00] INFO: Running start handlers
==> default: [2015-07-21T10:08:01+00:00] INFO: Start handlers complete.
==> default: Running handlers:
==> default: [2015-07-21T10:08:01+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2015-07-21T10:08:01+00:00] ERROR: Exception handlers complete
==> default: [2015-07-21T10:08:01+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: Chef Client failed. 0 resources updated in 0.736170145 seconds
==> default: [2015-07-21T10:08:01+00:00] ERROR: You must specify at least one cookbook repo path
==> default: [2015-07-21T10:08:01+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.
Vagrantfile
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 = "ubuntu/trusty64"
# 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: 8000, host: 8000
# config.omnibus.chef_version = :latest
config.omnibus.chef_version = "12.3.0"
# 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 "postgresql"
chef.add_recipe "postgresql::server"
chef.add_recipe "postgresql::client"
chef.json =
{
postgresql: {
users: [
{
"username" => "postgres",
"password" => "password",
"superuser" => true,
"replication" => false,
"createdb" => true,
"createrole" => false,
"inherit" => true,
"replication" => false,
"login" => true
}
]
}
}
end
end
Cheffile
site "http://community.opscode.com/api/v1"
cookbook 'apt'
cookbook 'nodejs'
cookbook 'build-essential'
cookbook 'postgresql', git: 'https://github.com/phlipper/chef-postgresql'
This vagrant-berkshelf issue looked similar, but deleting .vagrant.d, reloading and provisioning again didn't solve it.
What's causing this?
Thanks!
I installed Chef Dev Tools as this is the simplest way to install Berkshelf 3.0 on Windows. I set up a Berksfile in my project, based on my Cheffile, and enabled Berkshelf in the Vagrantfile. Now it provisions using Berkshelf, and it works.
Given there was no indication that Vagrant was using Berkshelf, I'm still not convinced that Berkshelf was the issue.
It would still be helpful to know how to install the latest Berkshelf version without Chef Dev Tools on Windows.
I want to spin up a Fedora-20 VM using Vagrant and Chef on my Windows 7 PC and provision it as a LAMP server. I have Vagrant 1.6.5. and the vagrant-omnibus plugin (1.4.1) is installed.
My Vagrantfile includes the "config.omnibus.chef_version = :latest" statement, but after running "vagrant up", expected provisioning does not occur. Instead,
==> default: Running provisioner: chef_solo...
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.
It appears that the omnibus plugin did not install Chef on the VM. What else do I need to do to get this working on my PC?
This is my Vagrant file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "chef/fedora-20"
config.omnibus.chef_version = :latest
config.vm.network "forwarded_port", guest: 80, host: 4567
config.vm.synced_folder "shared-files", "/var/www"
config.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "chef-recipes/cookbooks"
chef.roles_path = "chef-recipes/roles"
chef.add_role "lamp_stack"
end
end
and here is STDOUT:
C:\Users\wbj\f20>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'chef/fedora-20'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'chef/fedora-20' is up to date...
==> default: Setting the name of the VM: f20_default_1413836754304_46591
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 => 4567 (adapter 1)
default: 22 => 2222 (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: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /var/www => C:/Users/wbj/f20/shared-files
default: /vagrant => C:/Users/wbj/f20
default: /tmp/vagrant-chef-3/chef-solo-2/roles => C:/Users/wbj/f20/chef-recipes/roles
default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks => C:/Users/wbj/f20/chef-recipes/cookbooks
==> default: Running provisioner: chef_solo...
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.
Thank you!
I ran into this exact problem. The solution was to downgrade to Vagrant 1.6.2 until Vagrant version 1.7.1 was released. Both versions fixed the problem for me.
I'm trying to do some Vagrant/Ansible stuff, but running into problems from the start. Here's my Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.6.66"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "site.yml"
end
end
site.yml is simply
---
- name: Bring up server with MySQL, Nginx, and PHP-FPM
hosts: all
remote_user: root
roles:
- common
and common/tasks/main.yml is
---
- name: Update apt
apt: update_cache=yes
When doing vagrant up, the output is
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: ansible-provision_default_1412793587231_72507
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> 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 => 2200 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Checking for host entries
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /Users/bram/Projects/Brammm/ansible-provision
==> default: Running provisioner: ansible...
PLAY [Bring up server with MySQL, Nginx, and PHP-FPM] *************************
GATHERING FACTS ***************************************************************
fatal: [default] => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
TASK: [common | Update apt] ***************************************************
FATAL: no hosts matched or all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit #/Users/bram/site.retry
default : ok=0 changed=0 unreachable=1 failed=0
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
If I look at .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory, I see the following:
default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2200
I would expect the IP there to be the same as set in the private_network? I've been staring at this for over an hour, did I do something wrong? I have a feeling the IP isn't being set properly or something. I can ping 192.168.6.66.
The problem here that your site.yml overrides the remote user ansible will use to root. But, you do not provide the private key for it, nor password.
So the way, I fixed it was to set ansible_ssh_user to "vagrant", because it is default known user, and ansible will behave the same as vagrant ssh if remote_user is not overriden. And set sudo true, because "vagrant" user is sudoer, but not su.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.6.66"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "site.yml"
ansible.extra_vars = { ansible_ssh_user: 'vagrant' }
ansible.sudo = true
#ansible.verbose = 'vvvv'
end
end
Please refer to the "WHY DOES THE ANSIBLE PROVISIONER CONNECT AS THE WRONG USER?" section Ansible Provisioning of Vagrant Documentation
Vagrant will create it's own ansible inventory file (which you've seen) with the defaults of 127.0.0.1 and 2200.
You need to specify the ansible inventory file using ansible.inventory_path
A very simple inventory file for use with Vagrant might look like:
default ansible_ssh_host=192.168.111.222 Where the above IP address is
one set in your Vagrantfile:
config.vm.network :private_network, ip: "192.168.111.222"
From https://docs.vagrantup.com/v2/provisioning/ansible.html
I had Ansible on Vagrant 1.7 trying to connect as root, probably because of some separate deployment repo group vars defaults. Possible fixes:
set ansible.force_remote_user = true or ansible_ssh_user extra/host/group vars appropriately
or move to Vagrant 1.8, which forces remote user by default, as per the changelog
I was having a similar problem, where it wouldn't ssh into the server for whatever reason for provisioning.
vagrant ssh worked fine, but vagrant provision would fail to ssh, due to a timeout.
I finally connected the dots and realized that this was actually because of the VPN client that my employer has us use. Cisco AnyConnect VPN client does some kind of buggery and makes it so that I have to restart my entire workstation to be able to run it.
Luckily, I don't have to be connected to a VPN for many things, so this only happens sporadically for me.
Here's the output on running vagrant up. Besides this, I'm not even sure what information will be helpful.
puppetlabs-apache is available in subdir: modules
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Fixed port collision for 22 => 2222. Now on port 2200.
[default] Fixed port collision for 80 => 8080. Now on port 2201.
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2200 (adapter 1)
[default] -- 80 => 2201 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-puppet/manifests
[default] -- /tmp/vagrant-puppet/modules-0
[default] Running provisioner: puppet...
Running Puppet with default.pp...
stdin: is not a tty
warning: Could not retrieve fact fqdn
warning: Host is missing hostname and/or domain: precise32
Could not find class apache for precise32 at /tmp/vagrant-puppet/manifests/default.pp:5 on node precise32
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
cd /tmp/vagrant-puppet/manifests && puppet apply --verbose --debug --modulepath '/etc/puppet/modules:/tmp/vagrant-puppet/modules-0' default.pp --detailed-exitcodes || [ $? -eq 2 ]
You need to change the name of the folder from puppetlabs-apache to just apache. The module name must match the folder name.