UNREACHABLE! => {"changed": false, "msg": "Authentication or permission failure.

Good morning I have following question when I want to run Ansible-playbook by it:
sudo ansible-playbook -i hosts playbook.yml -u karol -k --become -K
I am getting following error:

fatal: [10.0.2.15]: UNREACHABLE! => {"changed": false, "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \" echo /home/karol/.ansible/tmp/ansible-tmp-1545340576.76-196881409171208 \" && echo ansible-tmp-1545340576.76-196881409171208=\" echo /home/karol/.ansible/tmp/ansible-tmp-1545340576.76-196881409171208 \" ), exited with result 1", "unreachable": true}
I can ssh to 10.0.2.15 without any issue.
What may be reason of my problem?
I was following steps from this place: https://github.com/openwisp/ansible-openwisp2#ansible-openwisp2
``

Hi,

This might happen if for some reason ansible was previously run on that host with root privileges (probably using sudo or su without changing the home directory). Please make sure that /home/karol/.ansible is in fact writable by the user ‘karol’.

kind regards
Pshem

Hello,

So how can I solve my issue? (I don’t have any idea what I can do with information below)

Since you are the karol user, why do you have to elevate the privilege by adding sudo before ansible-playbook only to downgrade it to karol with -u and then upgrade to root with --become?

Why can’t you just run
ansible-playbook -i hosts playbook.yml without the “sudo”, “-u karol” or “–become” ?

Has anyone else been able to connect to 10.0.2.15 with ansible-playbook without any issue?

I would try using the ping module to test the connectivity so it doesn’t require sudo access.

Another thing to try is to use ssh key instead of username/password to see if it makes any difference.