Ansible 在使用同步时提示密码 [英] Ansible prompts password when using synchronize
问题描述
我正在通过以下方式使用 ansible:
I'm using ansible in the following way:
ansible-playbook -f 1 my-play-book.yaml --ask-pass --ask-sudo-pass
在此之后,我被要求进入 ssh &sudo 密码(两者密码相同).
After this I'm asked to enter the ssh & sudo passwords (same password for both).
在我的剧本文件中,我正在使用同步任务:
Inside my playbook file I'm using synchronize task:
同步:mode=push src=rel/path/myfolder/dest=/abs/path/myfolder/
对于每个主机,我被提示输入远程主机的 ssh 密码(与我在 playbook 运行开始时输入的相同)
For each host, I'm prompted to enter the ssh password of the remote host (the same that I entered in the beginning of the playbook run)
如何避免在执行同步任务时输入密码?
How can I avoid entering the password when executing synchronize task?
推荐答案
如果您在 <host> 上正确设置了 ssh 密钥,那么以下应该可以工作.
If you have setup the ssh keys correctly on the <host>, then the following should work.
ansible all -m synchronize -a "mode=push src=rel/path/myfolder/ dest=/abs/path/myfolder/" -i <host>, -vvv
我能够在没有任何密码提示的情况下完成上述工作.
I was able to get the above working without any password prompt.
这篇关于Ansible 在使用同步时提示密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!