martin f. krafft | f37f068 | 2013-06-14 16:36:20 +0200 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | # |
| 4 | # ansible-adapter — adapter between Ansible and reclass |
| 5 | # |
| 6 | # Copyright © 2007–13 martin f. krafft <madduck@madduck.net> |
| 7 | # Released under the terms of the Artistic Licence 2.0 |
| 8 | # |
martin f. krafft | b37f9df | 2013-06-26 15:41:31 +0200 | [diff] [blame] | 9 | import os, sys, posix |
| 10 | |
| 11 | ansible_dir = os.path.dirname(sys.argv[0]) |
| 12 | |
| 13 | # In order to be able to use reclass as modules, manipulate the search |
| 14 | # path, starting from the location of the adapter. Realpath will make |
| 15 | # sure that symlinks are resolved. |
| 16 | realpath = os.path.realpath(sys.argv[0] + '/../../') |
| 17 | sys.path.insert(0, realpath) |
martin f. krafft | 7c64f9c | 2013-06-25 13:26:23 +0200 | [diff] [blame] | 18 | from reclass.adapters.ansible import ansible_adapter |
martin f. krafft | b37f9df | 2013-06-26 15:41:31 +0200 | [diff] [blame] | 19 | |
| 20 | def exc_handler(message, rc): |
| 21 | print >>sys.stderr, message |
| 22 | sys.exit(rc) |
| 23 | |
| 24 | ansible_adapter(ansible_dir, exc_handler) |
| 25 | sys.exit(posix.EX_OK) |