summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/error_from_connection
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/error_from_connection')
-rw-r--r--test/integration/targets/error_from_connection/aliases2
-rw-r--r--test/integration/targets/error_from_connection/connection_plugins/dummy.py42
-rw-r--r--test/integration/targets/error_from_connection/inventory2
-rw-r--r--test/integration/targets/error_from_connection/play.yml20
-rwxr-xr-xtest/integration/targets/error_from_connection/runme.sh5
5 files changed, 71 insertions, 0 deletions
diff --git a/test/integration/targets/error_from_connection/aliases b/test/integration/targets/error_from_connection/aliases
new file mode 100644
index 0000000..498fedd
--- /dev/null
+++ b/test/integration/targets/error_from_connection/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+context/controller
diff --git a/test/integration/targets/error_from_connection/connection_plugins/dummy.py b/test/integration/targets/error_from_connection/connection_plugins/dummy.py
new file mode 100644
index 0000000..59a81a1
--- /dev/null
+++ b/test/integration/targets/error_from_connection/connection_plugins/dummy.py
@@ -0,0 +1,42 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+DOCUMENTATION = """
+ author:
+ - John Doe
+ connection: dummy
+ short_description: defective connection plugin
+ description:
+ - defective connection plugin
+ version_added: "2.0"
+ options: {}
+"""
+import ansible.constants as C
+from ansible.errors import AnsibleError
+from ansible.plugins.connection import ConnectionBase
+
+
+class Connection(ConnectionBase):
+
+ transport = 'dummy'
+ has_pipelining = True
+
+ def __init__(self, play_context, new_stdin, *args, **kwargs):
+ super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
+
+ raise AnsibleError('an error with {{ some Jinja }}')
+
+ def _connect(self):
+ pass
+
+ def exec_command(self, cmd, in_data=None, sudoable=True):
+ pass
+
+ def put_file(self, in_path, out_path):
+ pass
+
+ def fetch_file(self, in_path, out_path):
+ pass
+
+ def close(self):
+ pass
diff --git a/test/integration/targets/error_from_connection/inventory b/test/integration/targets/error_from_connection/inventory
new file mode 100644
index 0000000..324f0d3
--- /dev/null
+++ b/test/integration/targets/error_from_connection/inventory
@@ -0,0 +1,2 @@
+[local]
+testhost
diff --git a/test/integration/targets/error_from_connection/play.yml b/test/integration/targets/error_from_connection/play.yml
new file mode 100644
index 0000000..04320d8
--- /dev/null
+++ b/test/integration/targets/error_from_connection/play.yml
@@ -0,0 +1,20 @@
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - name: "use a connection plugin raising an exception, exception message contains Jinja template."
+ connection: dummy
+ command: /bin/true # command won't be executed
+ register: result
+ ignore_errors: True
+
+ - name: "check that Jinja template embedded in exception message isn't rendered"
+ debug:
+ msg: 'ok'
+ when: result is failed
+ register: debug_task
+
+ - assert:
+ that:
+ - result is failed
+ - "'an error with' in result.msg" # makes sure plugin was found
+ - debug_task is success
diff --git a/test/integration/targets/error_from_connection/runme.sh b/test/integration/targets/error_from_connection/runme.sh
new file mode 100755
index 0000000..92679fd
--- /dev/null
+++ b/test/integration/targets/error_from_connection/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -o nounset -o errexit -o xtrace
+
+ansible-playbook -i inventory "play.yml" -v "$@"