ansible/ansible — pull request #7260 by rackergs (2014-05-02 20:36:55+00:00)
Title: Extend wait_for module to support draining of active tcp connections

note: I know it needs to be rebased and squashed, but i'd rather only do that once any potential changes are made post review

In our environment when we are doing updates we typically pull a node out of the load balancer pool but can't actually continue without at least a reasonable wait for active connections to close. To this end I implemented a state of 'drained' that checks for tcp connections (by parsing /proc/net/tcp) that match the defined host:port combination.

The load balancers do continue performing health checks, so the need to ignore certain connections was needed, thus adding the parameter exclude_hosts.

Example:

# wait 300 seconds for port 8000 of any IP to close active connections,
# don't start checking for 10 seconds
- wait_for: host=0.0.0.0 port=8000 delay=10 state=drained

# Same as above but excluding the firewalls
- wait_for: host=0.0.0.0 port=8000 delay=10 state=drained
exclude_hosts:10.10.10.15,10.10.10.16