Vagrant:Ansible通过提供设置主机条目

时间:2014-08-11 10:02:01

标签: vagrant ansible hosts

我又有一个问题。我正在寻找在不使用本地和来宾主机文件的情况下为vagrant ansible中的域设置主机条目的可能性。

我读了一些关于库存文件的内容,所以试了一下。以下内容位于文件本身中:

[myvm]
the-vm.local

这是我从

得到的错误
==> myvm: Running provisioner: ansible...
ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false PYTHONUNBUFFERED=1 ansible-playbook --private-key=/Users/me/.vagrant.d/insecure_private_key --user=vagrant --limit='myvm' --inventory-file=ansible/hosts -v ansible/playbook.yml

PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 
fatal: [the-vm.local] => 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: [Required packages present] ********************************************* 
FATAL: no hosts matched or all hosts have already failed -- aborting


PLAY RECAP ******************************************************************** 
       to retry, use: --limit @/Users/me/playbook.retry

the-vm.local               : 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.

任何线索如何解决这个问题还是有其他办法吗?

先谢谢!

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。问题在于ansible在我们的本地机器上运行,并且流浪的VM正在使用NAT。

答案是将VM网络设置为桥接,以便ansible可以从正在执行的计算机上解析主机名或IP(Vagrantfile修改):

config.vm.network :public_network

在“vagrant up”期间,控制台会要求您指定要连接的网络接口。

==> default: Available bridged network interfaces:
1) en1: Wi-Fi (AirPort)
2) en0: Ethernet
3) en3: Thunderbolt 1
4) bridge0
5) p2p0
    default: What interface should the network bridge to? 

来源:http://docs.ansible.com/guide_vagrant.html