I don’t think the failure is related to using or not using “sudo”. The playbook 
failed because Ansible could not connect to the remote machine. 

The error message:

        fatal: [myserver]: UNREACHABLE! => {"changed": false, "msg": "Failed to 
connect to the host via ssh: 
============================================================\n|Permission 
denied (publickey,password,keyboard-
        interactive).", "unreachable": true}

tells you that Ansible cannot connect to ‘myserver’ over SSH. If you try to 
connect to the target machine using SSH and the user ‘ansible’ from the command 
line, does that work? Do you have to type in a password? If you’re using SSH 
keys, does the ‘ansible’ user have permission to access the correct key?

See 
https://docs.ansible.com/ansible/latest/user_guide/connection_details.html#ssh-key-setup
 
<https://docs.ansible.com/ansible/latest/user_guide/connection_details.html#ssh-key-setup>
 for information on setting up SSH keys. 

Hope this helps point you in the right direction.

Alicia

> On Dec 6, 2019, at 10:44 AM, Xinhuan Zheng <xinhuan.zh...@gmail.com> wrote:
> 
> Hello,
> 
> 
> It's not necessary to use the "vars:" directive in the files. 
> See "Organizing host and group variables" 
> https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables
>  
> <https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables>
>  
> 
> # group_vars/all 
> remote_user: ansible 
> become: yes 
> become_method: sudo 
> 
> Cheers, 
> 
>         -vlado 
> 
> I changed per advice.  Here is my changed file:
> 
> ---
> # group_vars/all
> 
> remote_user: ansible
> become: yes
> become_method: sudo
> 
> However, this doesn't work either. I got same Permission Denied error like my 
> previous run
> 
> - Xinhuan Zheng
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to ansible-project+unsubscr...@googlegroups.com 
> <mailto:ansible-project+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/c0f93f0f-315a-47f5-a645-17a35bd7ae82%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/c0f93f0f-315a-47f5-a645-17a35bd7ae82%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/E938C3A5-4731-4512-BC55-AD48D75ADA20%40redhat.com.

Reply via email to