我需要传递用户名和密码,而不是使用无密码的SSH密钥。
我为此使用了以下命令
ansible-playbook -i hosts.ini main.yml --extra-vars "ansible_sudo_pass=$(ansible_password) ansible_user=$(ansible_user) ansible_ssh_pass=$(ansible_password)"
my inventory file hosts.ini
[all]
10.1.5.4
[defaults]
host_key_checking = false
[all:vars]
ansible_connection=ssh
timeout=20
Below is the error:
TASK [add_repo : Add repository] ***********************************************
fatal: [10.1.5.4]: FAILED! => {"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."}
Note I tried:
Removing in hosts.ini file
[defaults]
host_key_checking = false
I also tried by changing ansible_ssh_pass=$(ansible_password)
to ansible_password=$(ansible_password)