Refactor the Ansible adapter

Signed-off-by: martin f. krafft <madduck@madduck.net>
diff --git a/adapters/ansible.in b/adapters/ansible.in
index d225c9e..9ac7ea1 100644
--- a/adapters/ansible.in
+++ b/adapters/ansible.in
@@ -6,5 +6,20 @@
 # Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
 # Released under the terms of the Artistic Licence 2.0
 #
+import os, sys, posix
+
+ansible_dir = os.path.dirname(sys.argv[0])
+
+# In order to be able to use reclass as modules, manipulate the search
+# path, starting from the location of the adapter. Realpath will make
+# sure that symlinks are resolved.
+realpath = os.path.realpath(sys.argv[0] + '/../../')
+sys.path.insert(0, realpath)
 from reclass.adapters.ansible import ansible_adapter
-ansible_adapter()
+
+def exc_handler(message, rc):
+    print >>sys.stderr, message
+    sys.exit(rc)
+
+ansible_adapter(ansible_dir, exc_handler)
+sys.exit(posix.EX_OK)