I have a lab setup with ansible controller + node and exploring few areas.
I am so far setup an user account named ansible
in both machines and enabled ssh keybased authentication
Also setup sudo premissions for the user in both machines
When I try to run the below playbook , It works on the local machine and fails on the other node.
--- #Install Telnet
- hosts: all
name: Install Telnet
become: true
become_user: ansible
become_method: sudo
tasks:
- yum:
name: telnet
state: latest
Output is as follows `[ansible@host1 playbooks]$ ansible-playbook telnetDeployYUM.yml
PLAY [Install Telnet] ***********************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************** ok: [192.168.64.6] ok: [192.168.64.5]
TASK [yum] ********************************************************************************************************************************************************************************** ok: [192.168.64.5] fatal: [192.168.64.6]: FAILED! => {"changed": true, "msg": "You need to be root to perform this command.\n", "obsoletes": {"grub2": {"dist": "x86_64", "repo": "@anaconda", "version": "1:2.02-0.64.el7.centos"}, "grub2-tools": {"dist": "x86_64", "repo": "@anaconda", "version": "1:2.02-0.64.el7.centos"}}, "rc": 1, "results": ["Loaded plugins: fastestmirror\n"]} to retry, use: --limit @/home/ansible/playbooks/telnetDeployYUM.retry
PLAY RECAP ********************************************************************************************************************************************************************************** 192.168.64.5 : ok=2 changed=0 unreachable=0 failed=0 192.168.64.6 : ok=1 changed=0 unreachable=0 failed=1
[ansible@host1 playbooks]$ `
I could also manually able to run sudo yum
on the failed target as ansible user
I believe sudo set up in correct
[ansible@host2 root]$ sudo whoami
root
Can experts share some insights on what I am missing with respect to my failed machine , Thanks.