I’m trying to find a way to test an ssh connection to a specific user on a new server.
When I create a new virtual server, an ansible playbook is executed to finish the soft deployments:
1 Check if ssh is available (port 22)
2 Chekc if the ansible user is available
3 Get the uname
4 Install packages
I have no problem for 1, 3 and 4:
name: “waiting for host to start”
local_action: wait_for
host={{ inventory_hostname }}
state=started
port=22
delay=10
become: false
name: “waiting the uname”
command: uname -a
register: result
name: “uname”
debug:
var: result.stdout
but the second step is never OK. When the playbook execute this step, ansible execute the command, but never exit from this command. I have to kill the process of this command to force ansible to re-run a new test.
Finally when the server and user is available, after a new kill, ansible can continue with step 3.
How can I resolve this problem. I can add a sleep before the step 2, but it is not a good solution. Thanks in advance for your helps.
yess I've already tried shell butsame issue. If I try to connect
manually, it works. The problem is that ansible doesn't release the
first connection attemps while the server isn't ready. I don't know
why ...
I can’t reproduce the same run. Actually, ansible ask me to provide a password to connect. I don’t know why.
Ansible has to wait until he can connect using the command I provide no ?
i have add the vvv to ansible and to ssh command. The log provided comes from this run. I don’t have more logs. I will try tomorrow to make a new run just with the wait task.