User issue while pinging the hosts

Facing the below error while logging as my user (mahesh) and performing the actions on service user (service).

ERROR:
fatal: [10.0.0.1]: UNREACHABLE! => {“changed”: false, “msg”: “Authentication failure.”, “unreachable”: true}

Tried:

  • name: deploy elasticsearch
    hosts: all
    remote_user: mahesh
    become: yes
    become_user: service

Read these docs and make sure you understand them:

https://docs.ansible.com/ansible/latest/user_guide/connection_details.html

https://docs.ansible.com/ansible/latest/user_guide/become.html

Able to figure it out, there is no fault in site.yml, but in vars file i have added ansible_user as my service user, so initially it’s SSH as service user, which shouldn’t be the case.