wait for isn't waiting

For some reason this wait for is not working:

  • name: stop
    shell: /opt/tools/shutdown.sh
    wait_for
    port=8009
    state=stopped
    delay=15
    timeout=300

When running this in a playbook the playbook finishes immediately. I cannot for the life of me figure out why as port 8009 is open for a significant amount of time after the shell is executed.

Just a hint: the default host for the “port” version of “wait_for” is 127.0.0.1. If your service is bound to another interface (say, 192.168.5.5), then wait_for will not wait.
Y.

wait_for is a task, not a property of shell, it needs it's own task
block, also you might want to make it a 'local action' if that port is
related in any way to how you access that host.