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 ...
2016-12-12 13:58 UTC+01:00, Guilherme Ueno <[email protected]>: > Hi, > > Did you already try to use "shell" instead "command"? When you try to > execute that command from another machine it works? > > thanks, > Guilherme. > > On Monday, December 12, 2016 at 8:39:25 AM UTC-2, [email protected] wrote: >> >> Hi, forgive me for my bad english. >> >> 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 to connect to xxxx user" >> local_action: command ssh -i ~/.ssh/mykey -o ConnectTimeout=5 -o >> ConnectionAttempts=1 -o UserKnownHostsFile=/dev/null -o >> StrictHostKeyChecking=no -o GSSAPIAuthentication=no -o >> GSSAPIKeyExchange=no >> -l xxxxx {{inventory_hostname}} exit >> register: result >> until: result.rc == 0 >> retries: 20 >> delay: 5 >> >> - 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. >> > > -- > 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/cyOQIh3lPHM/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/04b175df-ec92-4579-a17c-d4efc100d23f%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- *reza.* -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAAxzbSRnVQxxux4HyK_jt4avVZ7NaZtzmjOEvj0kvF33ottbXw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
