I created my plugin first with 2.0 as a proof of concept (meaning I know it works by running it a few times; probably not ready for production). When I backported it to 1.9 (still as a POC; I'm working on getting it production ready now), it landed up not being that hard. Here's the big things that I've seen so far (the diff is FROM_2.0 to TO_1.9):
NOTE: I don't consider my work production ready, so... take it with a grain of salt. :-P
-from ansible.plugins.connection import ConnectionBase
-from ansible.utils.vars import combine_vars
+from ansible.callbacks import vv, vvv, vvvv, verbose # since Display doesn't seem to be in 1.9
-try:
- from __main__ import display
-except ImportError:
- from ansible.utils.display import Display
- display = Display()
-class Connection(ConnectionBase):
+class Connection(object):
# And because there is no ConnectionBase apparently, gotta get rid of those super() calls.
- def __init__(self, play_context, new_stdin, *args, **kwargs):
- super(Connection, self).__init__(play_context, new_stdin,
- *args, **kwargs)
+ def __init__(self, runner, host, port, user, password, *args, **kwargs):
- def _connect(self):
+ def connect(self): # Looks like 1.9 needs a public connect method
- def exec_command(self, cmd, in_data=None, sudoable=True):
- ''' run a command on the local host '''
- super(Connection, self).exec_command(cmd,
- in_data=in_data,
- sudoable=sudoable)
- display.vvv("EXEC length {}".format(len(cmd)))
+ def exec_command(self, cmd, tmp_path='', become_user=None, sudoable=False,
+ executable=None, in_data=None):