waits for password when I don't want it to

Hi all.

I have an environment with several hundred unreliable machines. Sometimes they’re just dead, sometimes they’re misconfigured. I always encounter some where the keys in my ssh-agent don’t work and it prompts me to enter the password and it waits for me to hit enter a bunch of times before the play will proceed.

Is there a way to configure ssh or ansible to just fail when this happens? I sometimes will run plays with password auth instead of ssh keys, so I don’t want to completely disable that.

Thanks!
-Dylan

You could set ssh to only use keys by setting the variable ansible_ssh_common_args="-o PreferredAuthentications=publickey".
It's also possible to set the environment variable ANSIBLE_SSH_COMMON_ARGS to the same value.