4
votes

I have created a Vagrantfile to provision a new box using Ansible. Both the Vagrantfile and the Ansible playbooks are ones I've used before, prior to an upgrade to OS X Yosemite. I can successfully vagrant up but when I try to vagrant provision I get the following error:

➜  NNL  vagrant provision
==> default: Running provisioner: ansible...
The executable 'ansible-playbook' Vagrant is trying to run was not
found in the PATH variable. This is an error. Please verify
this software is installed and on the path.    

Update 2: Here's the verbose (vvvv) output for the command above:

➜  ta  vagrant provision
==> default: Running provisioner: ansible...
ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false PYTHONUNBUFFERED=1 ANSIBLE_SSH_ARGS='-o  
ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-
key=/Users/mike/.vagrant.d/insecure_private_key --user=vagrant --connection=ssh --
limit='default' --inventory-file=/Users/mike/Desktop/ta/.vagrant/provisioners/ansible/inventory 
-vvvv vagrant.yml
The executable 'ansible-playbook' Vagrant is trying to run was not
found in the PATH variable. This is an error. Please verify
this software is installed and on the path.

I have already updated ansible and vagrant as part of my troubleshooting:

➜  NNL  ansible --version
ansible 1.8.1
  configured module search path = None
➜  NNL  ansible-playbook --version
ansible-playbook 1.8.1
  configured module search path = None
➜  NNL  vagrant --version
Vagrant 1.6.5

Ansible is definitely installed and /usr/local/bin is on the PATH environment variable.

➜  NNL  which ansible
/usr/local/bin/ansible
➜  NNL  echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Update 1: Here's my Vagrantfile, I've cut it back to the bare minimum:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    config.vm.box = "precise64"
    config.vm.hostname = "NNL"
    config.vm.box_url = "http://files.vagrantup.com/precise64.box"
    config.vm.network :forwarded_port, guest: 80, host: 8080
    config.vm.network :forwarded_port, guest: 3000, host: 3000
    config.vm.network :forwarded_port, guest: 9200, host: 9200
    config.ssh.forward_agent = true
    config.vm.provision "ansible" do |ansible|
      ansible.playbook = "vagrant.yml"
    end
end

My other thought was that I'm using zsh and perhaps vagrant is executing commands through bash or some other shell, so I also tried to add a .bashrc file to ensure that /usr/local/bin was on the path for that shell too. It appears to be, but I still get the same error:

➜  NNL  bash
bash-3.2$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
bash-3.2$ which ansible
/usr/local/bin/ansible

I'm at a loss now as to how to proceed. As a footnote, my other vagrant boxes which I created successfully under Mavericks also now fail with the same error when I try to re-provision them.

3
I don't know if it'll help, but can you post your Vagrantfile?tedder42
Sure thing, added to the question above.Teep
Add ansible.verbose = "vvvv" below the ansible.playbook setting so that we can get the full command vagrant is trying to runcodeaken
@codeaken Done as requested, see Update 2Teep

3 Answers

0
votes

I haven't used Yosemite so far, but if I understand well your same setup worked fine on a previous version of OS X.

First to collect a bit more information: when the vagrant box is up, could you please re-run the ansible-playbook command that is displayed in vagrant logs, but directly from a shell (bash or zsh should not matter):

ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false PYTHONUNBUFFERED=1 ANSIBLE_SSH_ARGS='-o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/Users/mike/.vagrant.d/insecure_private_key --user=vagrant --connection=ssh --limit='default' --inventory-file=/Users/mike/Desktop/ta/.vagrant/provisioners/ansible/inventory -vvvv vagrant.yml

What is the result?

If it works fine (which I expect, based on your problem description), then we are sure that we must chase something in Vagrant internals (in combination with Yosemite environment maybe).

0
votes

So finally I fixed the problem. Turns out an iTerm upgrade (to iTerm 2, June 2014) was needed. I don't fully understand the ins and outs of what was causing the problem but there's more information here: https://github.com/Homebrew/homebrew/issues/29843

0
votes

There is no need to install Ansible inside the Vagrant box. Ansible is agentless. Ansible uses SSH (or other protocols) to connect to other hosts. So there is no need to have Ansible executable inside the guest. You just need to have Ansible installed on the host running vagrant.