Revert "Track local_action internally to prevent it from being overridden"
This reverts commit 49ca0eb797
.
This commit is contained in:
parent
101c8785ec
commit
abf2e13955
3 changed files with 6 additions and 22 deletions
|
@ -254,7 +254,6 @@ class ModuleArgsParser:
|
|||
action, args = self._normalize_parameters(thing, additional_args=additional_args)
|
||||
|
||||
# local_action
|
||||
local_action = False
|
||||
if 'local_action' in self._task_ds:
|
||||
# local_action is similar but also implies a delegate_to
|
||||
if action is not None:
|
||||
|
@ -263,6 +262,8 @@ class ModuleArgsParser:
|
|||
delegate_to = 'localhost'
|
||||
action, args = self._normalize_parameters(thing, additional_args=additional_args)
|
||||
|
||||
# module: <stuff> is the more new-style invocation
|
||||
|
||||
# walk the input dictionary to see we recognize a module name
|
||||
for (item, value) in iteritems(self._task_ds):
|
||||
if item in module_loader or item == 'meta' or item == 'include':
|
||||
|
|
|
@ -95,10 +95,6 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
self._role = role
|
||||
self._task_include = task_include
|
||||
|
||||
# special flag for local_action: tasks, to make sure their
|
||||
# connection type of local isn't overridden incorrectly
|
||||
self._local_action = False
|
||||
|
||||
super(Task, self).__init__()
|
||||
|
||||
def get_path(self):
|
||||
|
@ -140,16 +136,6 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
t = Task(block=block, role=role, task_include=task_include)
|
||||
return t.load_data(data, variable_manager=variable_manager, loader=loader)
|
||||
|
||||
def load_data(self, ds, variable_manager=None, loader=None):
|
||||
'''
|
||||
We override load_data for tasks so that we can pull special flags
|
||||
out of the task args and set them internaly only so the user never
|
||||
sees them.
|
||||
'''
|
||||
t = super(Task, self).load_data(ds=ds, variable_manager=variable_manager, loader=loader)
|
||||
t._local_action = t.args.pop('_local_action', False)
|
||||
return t
|
||||
|
||||
def __repr__(self):
|
||||
''' returns a human readable representation of the task '''
|
||||
return "TASK: %s" % self.get_name()
|
||||
|
@ -280,7 +266,6 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
|
||||
def copy(self, exclude_block=False):
|
||||
new_me = super(Task, self).copy()
|
||||
new_me._local_action = self._local_action
|
||||
|
||||
new_me._block = None
|
||||
if self._block and not exclude_block:
|
||||
|
@ -298,7 +283,6 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
|
||||
def serialize(self):
|
||||
data = super(Task, self).serialize()
|
||||
data['_local_action'] = self._local_action
|
||||
|
||||
if self._block:
|
||||
data['block'] = self._block.serialize()
|
||||
|
@ -317,7 +301,6 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
#from ansible.playbook.task_include import TaskInclude
|
||||
|
||||
block_data = data.get('block')
|
||||
self._local_action = data.get('_local_action', False)
|
||||
|
||||
if block_data:
|
||||
b = Block()
|
||||
|
|
|
@ -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, connection = m.parse()
|
||||
self._debug(mod, args, connection)
|
||||
mod, args, delegate_to = m.parse()
|
||||
self._debug(mod, args, delegate_to)
|
||||
self.assertEqual(mod, 'copy')
|
||||
self.assertEqual(args, dict(src='a', dest='b', _local_action=True))
|
||||
self.assertIs(connection, 'local')
|
||||
self.assertEqual(args, dict(src='a', dest='b'))
|
||||
self.assertIs(delegate_to, 'localhost')
|
||||
|
||||
def test_multiple_actions(self):
|
||||
m = ModuleArgsParser(dict(action='shell echo hi', local_action='shell echo hi'))
|
||||
|
|
Loading…
Reference in a new issue