I’ve used ansible with some success on remote servers, but wanted to build up a quick playbook to build on dev boxes quickly.
So I wrote out a small playbook to just install some apt packages, and run it - but it seems to get “stuck” at Gathering Facts.
Any idea what might be missing ? I’ve installed openssh-server on the machine (assuming ansible needs this to connect) and I’m just connecting using my SSH password for now, to avoid any key issues.
I’ve enclosed the output below, with some verbose logging:
It’s most likely hung waiting for the sudo password, since you did not also specify the -K option to ansible-playbook. Add that option and you should get past the hang since it will prompt you for the sudo password.
Ansible performs SSH to the server @ username specified by -u option(the current logged in user if -u is missing). So if you don’t have passwordless sudo, then it will prompt you for a password. You are also missing --ask-pass option.
The correct systax is
ansible atlanta -a "/usr/bin/foo" -u username --sudo [--ask-sudo-pass]
Because I’m used to seeing the following prompts with the -kK options…
SSH password:
sudo password [defaults to SSH password]:
… and because, in this case, they ARE the same value, I’d assumed that the sudo password defaulted to the SSH password. Which it does… but of course it also hangs waiting for user input it if the -K option isn’t supplied !
One of those “now I see it, I can’t believe I didn’t see it” moments.
Generally this is related to Ansible somehow waiting for standard input, most commonly for a sudo or su password. I should note that I make this mistake all the time .
I’d check to make sure that you haven’t set sudo: yes or su: yes somewhere in the playbooks that you’re running. If you have, make sure to set the --ask-sudo-pass, --ask-su-pass arguments on ansible-playbook or use the su_pass, sudo_pass keywords in your tasks.