mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Surface module debug (-D) to /usr/bin/ansible also
This commit is contained in:
parent
d7e5b390d5
commit
2511992659
4 changed files with 18 additions and 0 deletions
|
@ -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())
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -17,12 +17,18 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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"
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue