0
votes

My mac machine is communicating with an ec2 instance, SSH connection is established and when it's pinged ,I am getting a response as "pong", but when I run playbook facing below issue.

but when I run playbook getting below error:

PLAY [macserver] ***************************************************************

TASK [Gathering Facts] *********************************************************
fatal: [X.X.X.X]: FAILED! => {"msg": "Missing sudo password"}

PLAY RECAP *********************************************************************
X.X.X.X : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

running the playbook as ec2-user, also just to check if issue is with ec2-user added new user as "ansible" in my linux ec2 instance and started running playbook, but still same issue is persisting. Also I have added ec2-user in sudoers file.

I tried alternative method to run playbook as specified below:

"ansible-playbook paybook.yml -k -K"

command to give password and run playbook, in that scenario facing incorrect sudo password error. Whereas the password created for root, ec2-user and ansible all are same. I am not able to figure out what and where I am missing, Can anyone help me with this?

1
You are connecting your Mac from EC2. "Missing sudo password" is not of root/ec2-user of EC2 server but of the Mac. You need to provide username/password/sudo access etc of target machine.saurabh14292
@saurabh14292 thanks this worked.. Also for others info: SSH password= host machine pw, become password=target machine password. few more questions, 1. does user matter???? one of my co-worker told need to use different user other than ec2-user? can I continue in ec2-user? 2.Consider if i have 5 target machines and all those machines have different password... what can we do in that scenario????ZAriel
Added comment and about ec2-user as answer.saurabh14292

1 Answers

0
votes

You are connecting your Mac from EC2. "Missing sudo password" is not of root/ec2-user of EC2 server but of the Mac. You need to provide username/password/sudo access etc of target machine

Regarding use of "ec2-user". You can continue with ec2-user or ubuntu user, which is a default user for EC2 instance. However, it is always a good practice to create a new user(s) with restricted accesses and delete the default user.