ansible -a sudo command hangs

172 views
Skip to first unread message

Tony Wong

unread,
Feb 10, 2022, 2:31:22 PM2/10/22
to Ansible Project
I am trying to run remote commands on few servers

ansible -a "df -h" myservers -i hosts -u "user" --assk-pass

this works

but when i do 

ansible -a "sudo systemctl status docker" -i hosts -u "user --ask-pass

then i enter my password

it just hangs

any idea?

Alex Wanderley

unread,
Feb 10, 2022, 3:43:43 PM2/10/22
to ansible...@googlegroups.com
Hello,

Yes, I have a clue: check your sudo configuration.
Very likely your sudo is set up in a way it is requiring an TTY for command executions. When Ansible sends a command it uses ssh, which usually does not provide a TTY.

Alex

--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c588d43d-40b6-4ba6-9ca7-027bdfe8e95bn%40googlegroups.com.


--

 

Edmonton_sig_RGB_S.jpg

Alex Wanderley

Application and Infrastructure Analyst II
Acting Team Lead Storage and Backup Solutions

Financial and Corporate Services | Open City and Technology  

 

780-496-4156  Office

780-819-0273  Mobile

 

City of Edmonton

Century Place, 12th Floor

9803 102A Avenue NW

Edmonton AB, T5J 3A3

 

All information contained in this email post is proprietary to the City of Edmonton, confidential and intended only for the addressed recipient. If you have received this post in error, please disregard the contents, inform the sender of the misdirection, and remove it from your system. The copying, dissemination or distribution of this email, if misdirected, is strictly prohibited.


The contents of this message and any attachment(s) are confidential, proprietary to the City of Edmonton, and are intended only for the addressed recipient. If you have received this in error, please disregard the contents, inform the sender of the misdirection, and remove it from your system. The copying, dissemination, or distribution of this message, if misdirected, is strictly prohibited.

Brian Coca

unread,
Feb 10, 2022, 5:55:56 PM2/10/22
to Ansible Project
try this instead:

ansible -a "systemctl status docker" -i hosts -u user --ask-pass -K --become


Adding (--become) makes ansible responsible for executing sudo (default become method) and passing in a password if needed (-K prompts you ahead of time for the sudo password)


--
----------
Brian Coca

Tony Wong

unread,
Feb 11, 2022, 9:01:10 AM2/11/22
to ansible...@googlegroups.com
thank you. that works. 

how do i save the users password and the become pass?

like I want to run

ansible -a "systemctl status docker" myhosts -i hosts --become

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/1gmhKgI8QkI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7dPqG-oRF1Xw-zaHLHCJfHeK2FEgXiaZ4DZrZ1cENetoQ%40mail.gmail.com.

Brian Coca

unread,
Feb 11, 2022, 2:36:28 PM2/11/22
to Ansible Project
Reply all
Reply to author
Forward
0 new messages