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 | # |
martin f. krafft | c2c355b | 2013-07-01 20:04:15 +0200 | [diff] [blame^] | 6 | # IMPORTANT NOTICE: I was kicked out of the Ansible community, and therefore |
| 7 | # I have no interest in developing this adapter anymore. If you use it and |
| 8 | # want to turn it into a setuptools entrypoints compatible adapter, I will |
| 9 | # take your patch. |
| 10 | # |
martin f. krafft | f37f068 | 2013-06-14 16:36:20 +0200 | [diff] [blame] | 11 | # Copyright © 2007–13 martin f. krafft <madduck@madduck.net> |
| 12 | # Released under the terms of the Artistic Licence 2.0 |
| 13 | # |
martin f. krafft | b37f9df | 2013-06-26 15:41:31 +0200 | [diff] [blame] | 14 | import os, sys, posix |
| 15 | |
| 16 | ansible_dir = os.path.dirname(sys.argv[0]) |
| 17 | |
| 18 | # In order to be able to use reclass as modules, manipulate the search |
| 19 | # path, starting from the location of the adapter. Realpath will make |
| 20 | # sure that symlinks are resolved. |
| 21 | realpath = os.path.realpath(sys.argv[0] + '/../../') |
| 22 | sys.path.insert(0, realpath) |
martin f. krafft | 7c64f9c | 2013-06-25 13:26:23 +0200 | [diff] [blame] | 23 | from reclass.adapters.ansible import ansible_adapter |
martin f. krafft | b37f9df | 2013-06-26 15:41:31 +0200 | [diff] [blame] | 24 | |
| 25 | def exc_handler(message, rc): |
| 26 | print >>sys.stderr, message |
| 27 | sys.exit(rc) |
| 28 | |
| 29 | ansible_adapter(ansible_dir, exc_handler) |
| 30 | sys.exit(posix.EX_OK) |