diff --git a/bin/ansible b/bin/ansible index c281212333..b069103d55 100755 --- a/bin/ansible +++ b/bin/ansible @@ -52,6 +52,8 @@ class Cli(object): help="module arguments", default=C.DEFAULT_MODULE_ARGS) parser.add_option('-B', '--background', dest='seconds', type='int', default=0, help='run asynchronously, failing after X seconds') + parser.add_option('-D','--debug', default=False, action="store_true", + help='enable standard error debugging of modules.') parser.add_option('-f','--forks', dest='forks', default=C.DEFAULT_FORKS, type='int', help='number of parallel processes to use') parser.add_option('-i', '--inventory-file', dest='inventory', @@ -109,6 +111,7 @@ class Cli(object): remote_port=options.remote_port, forks=options.forks, background=options.seconds, pattern=pattern, callbacks=self.callbacks, sudo=options.sudo, verbose=True, + debug=options.debug ) return (runner, runner.run()) diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 7cc4200811..fe2c8f4b1b 100755 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -86,6 +86,9 @@ class DefaultRunnerCallbacks(object): def on_ok(self, host, res): pass + def on_error(self, host, msg): + pass + def on_skipped(self, host): pass @@ -115,6 +118,9 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks): def on_skipped(self, host): pass + def on_error(self, host, err): + print >>sys.stderr, "stderr: [%s] => %s\n" % (host, err) + def _on_any(self, host, result): print utils.host_report_msg(host, self.options.module_name, result, self.options.one_line) if self.options.tree: diff --git a/library/failtest b/library/failtest index d6cb40ec11..10b1e63d03 100755 --- a/library/failtest +++ b/library/failtest @@ -17,12 +17,18 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +import sys + try: import json except ImportError: import simplejson as json +print >>sys.stderr, "THIS IS A TEST FAILURE" + print json.dumps({ "failed" : True, "msg" : "this module always fails" }) + + diff --git a/test/TestPlayBook.py b/test/TestPlayBook.py index 9fec3ef225..c0a3f28af0 100644 --- a/test/TestPlayBook.py +++ b/test/TestPlayBook.py @@ -42,6 +42,9 @@ class TestCallbacks(object): def on_import_for_host(self, host, filename): EVENTS.append([ 'import', [ host, filename ]]) + def on_error(self, host, msg): + EVENTS.append([ 'stderr', [ host, msg ]) + def on_not_import_for_host(self, host, missing_filename): pass