首页 文章

配置时,Vagrant无法运行

提问于
浏览
4

我创建了一个Vagrantfile来使用Ansible配置一个新的框 . 在升级到OS X Yosemite之前,Vagrantfile和Ansible剧本都是我之前使用过的 . 我可以成功 vagrant up 但是当我尝试 vagrant provision 时,我收到以下错误:

➜  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: 这是上面命令的详细(vvvv)输出:

➜  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.

作为我的故障排除的一部分,我已经更新了ansible和vagrant:

➜  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,并且/ usr / local / bin位于PATH环境变量上 .

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

Update 1: 这里's my Vagrantfile, I'已将其削减至最低限度:

# -*- 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

我的另一个想法是我正在使用zsh,也许vagrant正在通过bash或其他shell执行命令,所以我也尝试添加.bashrc文件以确保/ usr / local / bin也在该shell的路径上 . 它似乎是,但我仍然得到同样的错误:

➜  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

我现在不知道如何继续 . 作为一个脚注,当我尝试重新配置它时,我在Mavericks下成功创建的其他流浪盒现在也失败并出现相同的错误 .

3 回答

  • 0

    到目前为止我还没有使用Yosemite,但是如果我理解的话,你的相同设置在以前版本的OS X上运行良好 .

    首先收集更多信息:当流浪盒出现时,你可以重新运行在vagrant日志中显示的ansible-playbook命令,但是直接来自shell(bash或zsh应该无关紧要):

    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
    

    结果是什么?

    如果它工作正常(我希望,根据你的问题描述),那么我们确信我们必须在Vagrant内部追逐(可能与Yosemite环境相结合) .

  • 0

    所以最后我解决了这个问题 . 结果是需要iTerm升级(到iTerm 2,2014年6月) . 我在这里更多信息't fully understand the ins and outs of what was causing the problem but there':https://github.com/Homebrew/homebrew/issues/29843

  • 0

    无需在Vagrant框中安装Ansible . Ansible是无代理的 . Ansible使用SSH(或其他协议)连接到其他主机 . 因此,不需要在guest虚拟机中安装Ansible可执行文件 . 你只需要在运行vagrant的主机上安装Ansible .

相关问题