Re: [ansible-project] wait_for host : 100% CPU on deploy host

96 views
Skip to first unread message
Message has been deleted

Brian Coca

unread,
May 26, 2015, 9:55:13 AM5/26/15
to ansible...@googlegroups.com
it is basically a 'wait loop' but it does have some sleeps in there to
avoid chewing on CPU, in your case the statement wil just do nothing
for 20s and then wait for another 300 w/o doing anything. This path
has no internal sleep in the loop (path and socket do) so that is
probably why the CPU is being killed by a tight loop.


test out this PR and see if it fixes the issue for you
https://github.com/ansible/ansible-modules-core/pull/1422

--
Brian Coca

Toshio Kuratomi

unread,
May 26, 2015, 10:19:44 AM5/26/15
to ansible...@googlegroups.com
bcoca answered about why the wait_for is taking so much CPU but
there's another part of your question as well -- why it's taking so
long.

If you don't specify a port or a path then ansible is just waiting for
a set amount of time before it goes to the next task. The default
value of timeout is 300 so should be about 5 minutes. Since you are
checking a host that's in your inventory you probably want to check
for the ssh port becoming active instead. Something like this:

- name: Wait for the host to accept ssh connections
wait_for:
host: "{{ inventory_hostname }}"
port: 22
delay: 20
timeout: 300
state: started

That will wait until port 22 is available on inventory_hostname or the
timeout of 300s (plus the delay of 20s before the first check is
performed) has expired.

-Toshio

On Tue, May 26, 2015 at 3:10 AM, Florent B <flo...@coppint.com> wrote:
> Hi everyone,
>
> I use Ansible 1.9.1 on an Ubuntu 15.04 deploy host.
>
> I manage some Debian hosts.
>
> When I use this command to wait for an host after reboot :
>
> local_action: wait_for host={{ inventory_hostname }} state=started delay=20
> sudo: false
>
> It creates a python process on my deploy host, which is taking 100% of
> my CPU (of a core, of course).
>
> The command works, but it detects that a host is back after a very long
> delay after it really comes back (host comes back at T0, and Ansible
> detects it up at T0+2 minutes for example).
>
> Am I doing something wrong ?
>
> Is it a bug ?
>
> Thank you
>
> --
> 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 post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5564468F.7060006%40coppint.com.
> For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
May 26, 2015, 10:20:42 AM5/26/15
to ansible...@googlegroups.com
you might also want to make it a local_action
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAG9juEoqKKfKDqUhKcVQRJVqaZpavoczN_ABQ9OdG7KgcYTxmQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages