diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2014-11-11 15:09:42 -0500 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2016-12-08 11:22:25 -0500 |
commit | 7d577e4447fe9037bbf9be9bace71a56e437c1b4 (patch) | |
tree | 0208165c9543eae0444f490ec751b75e289de7cd /lib/ansible | |
parent | 5d103793eee0c32d9e5ffa33a4fde3bd2034d5fc (diff) | |
download | ansible-7d577e4447fe9037bbf9be9bace71a56e437c1b4.tar.gz |
minor fixes to wait_for to avoid tracebacks as per ansible core issue #9244
Diffstat (limited to 'lib/ansible')
-rw-r--r-- | lib/ansible/modules/utilities/logic/wait_for.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/ansible/modules/utilities/logic/wait_for.py b/lib/ansible/modules/utilities/logic/wait_for.py index 2d62428267..88e821cfdb 100644 --- a/lib/ansible/modules/utilities/logic/wait_for.py +++ b/lib/ansible/modules/utilities/logic/wait_for.py @@ -170,7 +170,7 @@ class TCPConnectionInfo(object): def _get_exclude_ips(self): if self.module.params['exclude_hosts'] is None: return [] - exclude_hosts = self.module.params['exclude_hosts'].split(',') + exclude_hosts = self.module.params['exclude_hosts'] return [ _convert_host_to_hex(h)[1] for h in exclude_hosts ] def get_active_connections_count(self): @@ -221,7 +221,7 @@ class LinuxTCPConnectionInfo(TCPConnectionInfo): def _get_exclude_ips(self): if self.module.params['exclude_hosts'] is None: return [] - exclude_hosts = self.module.params['exclude_hosts'].split(',') + exclude_hosts = self.module.params['exclude_hosts'] return [ _convert_host_to_hex(h) for h in exclude_hosts ] def get_active_connections_count(self): @@ -305,7 +305,7 @@ def main(): path=dict(default=None), search_regex=dict(default=None), state=dict(default='started', choices=['started', 'stopped', 'present', 'absent', 'drained']), - exclude_hosts=dict(default=None, type='list') + exclude_hosts=dict(default=None) ), ) @@ -322,20 +322,18 @@ def main(): state = params['state'] path = params['path'] search_regex = params['search_regex'] - if params['exclude_hosts']: - exclude_hosts = params['exclude_hosts'].split(',') - else: - exclude_hosts = [] - + if isinstance(params['exclude_hosts'], basestring): + params['exclude_hosts'] = params['exclude_hosts'].split(',') + if port and path: module.fail_json(msg="port and path parameter can not both be passed to wait_for") if path and state == 'stopped': module.fail_json(msg="state=stopped should only be used for checking a port in the wait_for module") if path and state == 'drained': module.fail_json(msg="state=drained should only be used for checking a port in the wait_for module") - if exclude_hosts and state != 'drained': + if params['exclude_hosts'] is not None and state != 'drained': module.fail_json(msg="exclude_hosts should only be with state=drained") - + start = datetime.datetime.now() if delay: |