From 71c97685a13e82a4448e9496adb8f5fbe3cfeb4b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 22 Jul 2016 20:35:20 -0400 Subject: [PATCH] fixes for service module interaction with systemd (#16720) now systemd will run even if service module is inovked with parameters that it does not support these will be removed before invoking systemd and issue a warning. this facility will work for any new service modules. --- lib/ansible/plugins/action/service.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/ansible/plugins/action/service.py b/lib/ansible/plugins/action/service.py index 65cbe8b0e0..3648fa3a44 100644 --- a/lib/ansible/plugins/action/service.py +++ b/lib/ansible/plugins/action/service.py @@ -25,6 +25,10 @@ class ActionModule(ActionBase): TRANSFERS_FILES = False + UNUSED_PARAMS = { + 'systemd': ['pattern', 'runlevels', 'sleep', 'arguments'], + } + def run(self, tmp=None, task_vars=None): ''' handler for package operations ''' if task_vars is None: @@ -59,6 +63,12 @@ class ActionModule(ActionBase): if 'state' in new_module_args and new_module_args['state'] == 'running': new_module_args['state'] = 'started' + if module in self.UNUSED_PARAMS: + for unused in self.UNUSED_PARAMS[module]: + if unused in new_module_args: + del new_module_args[unused] + self._display.warning('Ignoring "%s" as it is not used in "%s"' % (unused, module)) + self._display.vvvv("Running %s" % module) result.update(self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars)) else: