Vagrant 1.8.0現在有new Ansible local provisioner,您可以在您的方案中使用它。
特別是,看文檔的「提示和技巧」部分,有一個確切的解決方案(這對我有效)。
下面是我Vagrantfile對於這種情況,這也解決了潛在的問題與SSH權限和「執行」清單文件(如果你使用Cygwin)(從一個文檔中的略有不同):
Vagrant.configure(2) do |config|
config.vm.synced_folder "./", "/vagrant",
owner: "vagrant",
mount_options: ["dmode=775,fmode=600"]
config.vm.define "vm2" do |machine|
machine.vm.box = "box-cutter/ubuntu1404-desktop"
machine.vm.network "private_network", ip: "172.17.177.21"
end
config.vm.define 'vm1' do |machine|
machine.vm.box = "ubuntu/trusty64"
machine.vm.network "private_network", ip: "172.17.177.11"
machine.vm.provision :ansible_local do |ansible|
ansible.provisioning_path = "/vagrant"
ansible.playbook = "provisioning/playbook.yml"
ansible.limit = "vm2"
ansible.inventory_path = "inventory"
ansible.verbose = "vvv"
ansible.install = true
end
end
end
和庫存文件:
vm1 ansible_connection=local
vm2 ansible_ssh_host=172.17.177.21 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/vm2/virtualbox/private_key
的可能的複製[?能否提供流浪漢虛擬機使用別的流浪VM的Ansible安裝(http://stackoverflow.com/questions/33393748/can-vagrant-provision -vm-using-an-ansible-installation-in-another-vagrant-vm) – ydaetskcoR