我的Vagrantfile中有4个VM-3个应用程序服务器和一个Ansible控制主机。
我只使用Vagrant来创建VM,因为我仍在创建/编辑Ansible脚本时,从Ansible控制主机手动配置它们。
我可以执行其他操作vagrant ssh ansible
,vagrant ssh app1/2/3
但是当我尝试ansible-playbook oracle.yml
从Ansible控制主机执行操作时,SSH失败并显示
fatal: [192.168.60.10]: UNREACHABLE! => {"changed": false, "msg": "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", "unreachable": true}
我可以使用用户无业游民和密码无业游民成功地将Ansible VM切换到Oracle VM。
我的Vagrantfile的关键部分是:
config.ssh.insert_key = false
config.vm.define "db" do |db|
db.vm.box = "boxcutter/ol67"
db.vm.hostname = "oracle-vm"
db.vm.network "forwarded_port", guest: 22, host: 2201, id: "ssh", auto_correct: false
db.vm.network "forwarded_port", guest: 1521, host: 1521
db.vm.network "private_network", ip: "192.168.60.10"
db.vm.provider "virtualbox" do |v|
v.name = "oracle-vm"
v.linked_clone = true
v.memory = 2048
v.cpus = 2
end
end
#Optional ansible control machine for Windows users
config.vm.define "ansible", autostart: false do |ansible|
ansible.vm.box = "williamyeh/ansible"
ansible.vm.hostname = "ansible-vm"
ansible.vm.network "forwarded_port", guest: 22, host: 2204, id: "ssh", auto_correct: false
ansible.vm.network "private_network", ip: "192.168.60.50"
ansible.vm.provider "virtualbox" do |v|
v.linked_clone = true
end
#Mount the project directory on the guest so we can run the playbooks from there
ansible.vm.synced_folder ".", "/data/ansible", create: true
end
我需要放入Vagrant文件中以允许Ansible VM连接到其他VM,而无需输入密码或之后不需要其他手动步骤vagrant up
?
这仅用于在开发人员PC上的专用网络上进行开发测试,因此安全性并不是真正的问题,其次是易于实现和流畅的用户体验。