wait_for host : 100% CPU on deploy host

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

you might also want to make it a local_action