I am using Ansible to create and setup new virtual machine.
after the VM is created, if I use playbook to setup VM
ansible-playbook config-vm.yml -i …/…/vms --extra-vars “target=10.150.200.30” --extra-vars “@password.json” --vault-password-file ~/vault-password.txt
Then I get this error
UNREACHABLE! => {“changed”: false, “msg”: "Failed to connect to the host via ssh: Shared connection to 10.150.200.30 closed.\r\n", “unreachable”: true}
but if I explicitly ask the password
ansible-playbook config-vm.yml -i …/…/vms --extra-vars “target=10.150.200.30” --ask-pass --ask-become-pass --ask-vault-pass
it will work.
How to solve this issue, I don’t want to type the password during setup process.