ansible: don't crash when adhoc tries to run a missing module.

ansible-playbook prints a separate error during parsing stage, adhoc
performs no such check.
pull/350/head
David Wilson 6 years ago
parent 34a9f67115
commit 6c4b01642c

@ -55,6 +55,7 @@ import ansible_mitogen.target
LOG = logging.getLogger(__name__)
NO_METHOD_MSG = 'Mitogen: no invocation method found for: '
NO_INTERPRETER_MSG = 'module (%s) is missing interpreter line'
NO_MODULE_MSG = 'The module %s was not found in configured module paths.'
class Invocation(object):
@ -393,6 +394,9 @@ _planners = [
def get_module_data(name):
path = ansible_mitogen.loaders.module_loader.find_plugin(name, '')
if path is None:
raise ansible.errors.AnsibleError(NO_MODULE_MSG % (name,))
with open(path, 'rb') as fp:
source = fp.read()
return mitogen.core.to_text(path), source

@ -15,3 +15,4 @@
- import_playbook: environment_isolation.yml
- import_playbook: etc_environment.yml
- import_playbook: forking_behaviour.yml
- import_playbook: missing_module.yml

@ -0,0 +1,15 @@
- name: integration/runner/missing_module.yml
hosts: test-targets
connection: local
tasks:
- connection: local
command: ansible -i localhost, localhost -m missing_module
args:
chdir: ../..
register: out
ignore_errors: true
- assert:
that: |
'The module missing_module was not found in configured module paths.' in out.stdout
Loading…
Cancel
Save