Surface module debug (-D) to /usr/bin/ansible also

pull/101/head
Michael DeHaan 13 years ago
parent d7e5b390d5
commit 2511992659

@ -52,6 +52,8 @@ class Cli(object):
help="module arguments", default=C.DEFAULT_MODULE_ARGS) help="module arguments", default=C.DEFAULT_MODULE_ARGS)
parser.add_option('-B', '--background', dest='seconds', type='int', default=0, parser.add_option('-B', '--background', dest='seconds', type='int', default=0,
help='run asynchronously, failing after X seconds') 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', parser.add_option('-f','--forks', dest='forks', default=C.DEFAULT_FORKS, type='int',
help='number of parallel processes to use') help='number of parallel processes to use')
parser.add_option('-i', '--inventory-file', dest='inventory', parser.add_option('-i', '--inventory-file', dest='inventory',
@ -109,6 +111,7 @@ class Cli(object):
remote_port=options.remote_port, forks=options.forks, remote_port=options.remote_port, forks=options.forks,
background=options.seconds, pattern=pattern, background=options.seconds, pattern=pattern,
callbacks=self.callbacks, sudo=options.sudo, verbose=True, callbacks=self.callbacks, sudo=options.sudo, verbose=True,
debug=options.debug
) )
return (runner, runner.run()) return (runner, runner.run())

@ -86,6 +86,9 @@ class DefaultRunnerCallbacks(object):
def on_ok(self, host, res): def on_ok(self, host, res):
pass pass
def on_error(self, host, msg):
pass
def on_skipped(self, host): def on_skipped(self, host):
pass pass
@ -115,6 +118,9 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks):
def on_skipped(self, host): def on_skipped(self, host):
pass pass
def on_error(self, host, err):
print >>sys.stderr, "stderr: [%s] => %s\n" % (host, err)
def _on_any(self, host, result): def _on_any(self, host, result):
print utils.host_report_msg(host, self.options.module_name, result, self.options.one_line) print utils.host_report_msg(host, self.options.module_name, result, self.options.one_line)
if self.options.tree: if self.options.tree:

@ -17,12 +17,18 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import sys
try: try:
import json import json
except ImportError: except ImportError:
import simplejson as json import simplejson as json
print >>sys.stderr, "THIS IS A TEST FAILURE"
print json.dumps({ print json.dumps({
"failed" : True, "failed" : True,
"msg" : "this module always fails" "msg" : "this module always fails"
}) })

@ -42,6 +42,9 @@ class TestCallbacks(object):
def on_import_for_host(self, host, filename): def on_import_for_host(self, host, filename):
EVENTS.append([ 'import', [ 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): def on_not_import_for_host(self, host, missing_filename):
pass pass

Loading…
Cancel
Save