From 7a4a156d91bb93b532c0b93151de6cbd81d00802 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 18 Aug 2015 18:31:29 -0400 Subject: [PATCH 1/2] changed local_action to alias to connection=local vs delegate_to=localhost fixes #11998, but still leaves issue of delegate_to: localhost not working --- lib/ansible/parsing/mod_args.py | 11 +++++------ lib/ansible/playbook/task.py | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/ansible/parsing/mod_args.py b/lib/ansible/parsing/mod_args.py index 8a084587d0e..6b10dd53085 100644 --- a/lib/ansible/parsing/mod_args.py +++ b/lib/ansible/parsing/mod_args.py @@ -234,10 +234,9 @@ class ModuleArgsParser: task, dealing with all sorts of levels of fuzziness. ''' - thing = None - + thing = None action = None - delegate_to = self._task_ds.get('delegate_to', None) + connection = self._task_ds.get('connection', None) args = dict() @@ -256,11 +255,11 @@ class ModuleArgsParser: # local_action if 'local_action' in self._task_ds: - # local_action is similar but also implies a delegate_to + # local_action is similar but also implies a connection='local' if action is not None: raise AnsibleParserError("action and local_action are mutually exclusive", obj=self._task_ds) thing = self._task_ds.get('local_action', '') - delegate_to = 'localhost' + connection = 'local' action, args = self._normalize_parameters(thing, additional_args=additional_args) # module: is the more new-style invocation @@ -289,4 +288,4 @@ class ModuleArgsParser: # shell modules require special handling (action, args) = self._handle_shell_weirdness(action, args) - return (action, args, delegate_to) + return (action, args, connection) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index f0023fecf48..ee6bbbacba2 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -157,11 +157,11 @@ class Task(Base, Conditional, Taggable, Become): # and the delegate_to value from the various possible forms # supported as legacy args_parser = ModuleArgsParser(task_ds=ds) - (action, args, delegate_to) = args_parser.parse() + (action, args, connection) = args_parser.parse() new_ds['action'] = action new_ds['args'] = args - new_ds['delegate_to'] = delegate_to + new_ds['connection'] = connection # we handle any 'vars' specified in the ds here, as we may # be adding things to them below (special handling for includes). @@ -174,7 +174,7 @@ class Task(Base, Conditional, Taggable, Become): new_ds['vars'] = dict() for (k,v) in ds.iteritems(): - if k in ('action', 'local_action', 'args', 'delegate_to') or k == action or k == 'shell': + if k in ('action', 'local_action', 'args', 'connection') or k == action or k == 'shell': # we don't want to re-assign these values, which were # determined by the ModuleArgsParser() above continue From 69f380da3af5cf19c2c606c052ba4b1b68df9eb4 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 19 Aug 2015 00:34:37 -0400 Subject: [PATCH 2/2] changed mod_args test to match connection --- test/units/parsing/test_mod_args.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/units/parsing/test_mod_args.py b/test/units/parsing/test_mod_args.py index 187edfa03cb..bce31d6f1f8 100644 --- a/test/units/parsing/test_mod_args.py +++ b/test/units/parsing/test_mod_args.py @@ -109,11 +109,11 @@ class TestModArgsDwim(unittest.TestCase): def test_local_action_string(self): m = ModuleArgsParser(dict(local_action='copy src=a dest=b')) - mod, args, to = m.parse() - self._debug(mod, args, to) + mod, args, connection = m.parse() + self._debug(mod, args, connection) self.assertEqual(mod, 'copy') self.assertEqual(args, dict(src='a', dest='b')) - self.assertIs(to, 'localhost') + self.assertIs(connection, 'local') def test_multiple_actions(self): m = ModuleArgsParser(dict(action='shell echo hi', local_action='shell echo hi'))