issue #118: log exceptions for emulated commands, fix AttributeError in helpers.py

Turns out Ansible can't be trusted to actually check the result
dictionary everywhere it expects one, so put the real exception text
into -vvv output too.
This commit is contained in:
David Wilson 2018-03-08 20:22:08 +05:45
parent 6106c27707
commit 9b7991cd45
2 changed files with 6 additions and 1 deletions

View File

@ -289,7 +289,7 @@ def set_file_mode(path, spec):
"""
mode = os.stat(path).st_mode
if spec.is_digit():
if spec.isdigit():
new_mode = int(spec, 8)
else:
new_mode = apply_mode_spec(spec, mode)

View File

@ -28,6 +28,7 @@
from __future__ import absolute_import
import commands
import logging
import os
import pwd
import shutil
@ -52,6 +53,9 @@ import ansible_mitogen.helpers
from ansible.module_utils._text import to_text
LOG = logging.getLogger(__name__)
def get_command_module_name(module_name):
"""
Given the name of an Ansible command module, return its canonical module
@ -157,6 +161,7 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
if stdout:
dct['stdout'] = repr(rc)
except mitogen.core.CallError:
LOG.exception('While emulating a shell command')
dct['rc'] = 1
dct['stderr'] = traceback.format_exc()