Ansible SSH error although standard ssh is working
You need to set the connection to local
for localhost.
Create a file host_vars/localhost
relative to your playbook with following content:
---
ansible_connection: local
...
Alternatively you could call ansible-playbook with the --connection=local
option but it's good to have the above file in place in case you want to delegate a task to localhost.