From 19797e1a29f3b4e4ab7457603c60406692719023 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 18 Oct 2012 21:48:10 +0200 Subject: [PATCH] Accessing a node that doesn't exist throws an exception --- lib/ansible/runner/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 07e8a001bd..61ff6ff427 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -391,9 +391,12 @@ class Runner(object): delegate_to = inject.get('delegate_to', None) if delegate_to is not None: delegate_to = utils.template(self.basedir, delegate_to, inject) - delegate_info = inject['hostvars'][delegate_to] - actual_host = delegate_info.get('ansible_ssh_host', delegate_to) - actual_port = delegate_info.get('ansible_ssh_port', port) + try: + delegate_info = inject['hostvars'][delegate_to] + actual_host = delegate_info.get('ansible_ssh_host', delegate_to) + actual_port = delegate_info.get('ansible_ssh_port', port) + except errors.AnsibleError: + actual_host = delegate_to try: # connect