1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

package and service now check that module exists before trying to execute it

This commit is contained in:
Brian Coca 2015-08-31 13:25:07 -04:00
parent bca4e23b27
commit 7458331539
2 changed files with 6 additions and 1 deletions

View file

@ -44,6 +44,10 @@ class ActionModule(ActionBase):
module = getattr(facts['ansible_facts'], 'ansible_pkg_mgr', 'auto') module = getattr(facts['ansible_facts'], 'ansible_pkg_mgr', 'auto')
if module != 'auto': if module != 'auto':
if module not in self._shared_loader_obj.module_loader:
return {'failed': True, 'msg': 'Could not find a module for %s.' % module}
# run the 'package' module # run the 'package' module
new_module_args = self._task.args.copy() new_module_args = self._task.args.copy()
if 'use' in new_module_args: if 'use' in new_module_args:

View file

@ -20,6 +20,7 @@ __metaclass__ = type
from ansible.plugins.action import ActionBase from ansible.plugins.action import ActionBase
class ActionModule(ActionBase): class ActionModule(ActionBase):
TRANSFERS_FILES = False TRANSFERS_FILES = False
@ -43,7 +44,7 @@ class ActionModule(ActionBase):
if not 'failed' in facts: if not 'failed' in facts:
module = getattr(facts['ansible_facts'], 'ansible_service_mgr', 'auto') module = getattr(facts['ansible_facts'], 'ansible_service_mgr', 'auto')
if not module or module == 'auto': if not module or module == 'auto' or module not in self._shared_loader_obj.module_loader:
module = 'service' module = 'service'
if module != 'auto': if module != 'auto':