Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting options is fine if plugins already exist #44859

Merged
merged 1 commit into from
Aug 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/ansible/plugins/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ def __getattr__(self, name):
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))

def _connect(self):
for plugin in self._implementation_plugins:
plugin.set_options(*self._cached_variables)
self.set_implementation_plugin_options(*self._cached_variables)
self._cached_variables = (None, None, None)

def exec_command(self, cmd, in_data=None, sudoable=True):
Expand Down Expand Up @@ -350,7 +349,18 @@ def close(self):

def set_options(self, task_keys=None, var_options=None, direct=None):
super(NetworkConnectionBase, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self._cached_variables = (task_keys, var_options, direct)

if self._implementation_plugins:
self.set_implementation_plugin_options(task_keys, var_options, direct)
else:
self._cached_variables = (task_keys, var_options, direct)

def set_implementation_plugin_options(self, task_keys=None, var_options=None, direct=None):
'''
initialize implementation plugin options
'''
for plugin in self._implementation_plugins:
plugin.set_options(task_keys=task_keys, var_options=var_options, direct=direct)

def _update_connection_state(self):
'''
Expand Down