Skip to content

Commit

Permalink
Add vendor neutral parameter fail_on_missing_module (ansible#26482)
Browse files Browse the repository at this point in the history
By default, the vendor neutral modules will just go on if no
implementation module is found.
If user specifies the task argument fail_on_missing_module and
sets it to True, then we bail out the play early and report that
to the user.
  • Loading branch information
rcarrillocruz authored Jul 6, 2017
1 parent c6c5c6c commit 5acebc1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/ansible/plugins/action/net_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,19 @@ def run(self, tmp=None, task_vars=None):
socket_path = self._start_connection(play_context)
task_vars['ansible_socket'] = socket_path

if 'fail_on_missing_module' not in self._task.args:
self._task.args['fail_on_missing_module'] = False

result = super(ActionModule, self).run(tmp, task_vars)

module = self._get_implementation_module(play_context.network_os, self._task.action)

if not module:
result['failed'] = True
if self._task.args['fail_on_missing_module']:
result['failed'] = True
else:
result['failed'] = False

result['msg'] = ('Could not find implementation module %s for %s' %
(self._task.action, play_context.network_os))
else:
Expand All @@ -83,6 +90,8 @@ def run(self, tmp=None, task_vars=None):
if 'network_os' in new_module_args:
del new_module_args['network_os']

del new_module_args['fail_on_missing_module']

display.vvvv('Running implementation module %s' % module)
result.update(self._execute_module(module_name=module,
module_args=new_module_args, task_vars=task_vars,
Expand Down

0 comments on commit 5acebc1

Please sign in to comment.