Skip to content

Commit 801c190

Browse files
committed
ansible-ssh: exit if no host match
prevents Traceback (most recent call last): File dev/ansible-ssh, line 53, in <module> result = output.splitlines()[0].split('>', 1)[-1] IndexError: list index out of range
1 parent 30de1c4 commit 801c190

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

dev/ansible-ssh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ if __name__ == "__main__":
4949
# output looks like e.g.
5050
# stg-login-0 | SUCCESS => { "changed": false, ...
5151
# one line per host
52+
if not output:
53+
sys.exit(1)
5254
result = output.splitlines()[0].split('>', 1)[-1]
5355
expanded = json.loads(result)['msg']
5456
# can assume ansible_host exists b/c defined by terraform

0 commit comments

Comments
 (0)