0
我跟着從官方教程:http://docs.ansible.com/ansible/guide_vagrant.html如何在本地使用Ansible和Vagrant?
我Vagrantfile
樣子:
VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'bento/centos-7.2'
# SSH default root user
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
# Networking
# config.vm.network :private_network, ip: '192.168.33.16'
# Provisioning
config.vm.provision :ansible do |ansible|
ansible.playbook = 'playbooks/main.yml'
end
end
而且我test.sh
腳本:
ansible-playbook \
--private-key=.vagrant/machines/default/virtualbox/private_key \
-u vagrant \
-i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory \
playbooks/main.yml \
[email protected]
但是當我運行該腳本,我收到以下錯誤:
fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
to retry, use: --limit @playbooks/main.retry
PLAY RECAP *********************************************************************
default : ok=0 changed=0 unreachable=1 failed=0
如何測試ansible-playbook
與Vagrant
?
您可以使用'-i「localhost,''對本地主機運行一個手冊。但你確定這就是你想要的嗎?你不想針對你創建的虛擬機運行嗎? –
也許我對你的問題的標題讀得太多了。 –
我創建了Vagrant機器,並且我想要再次運行特定的Playbook。 – squixy