From 86c714548fd5be8adc7243410f5219ddcef28817 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Fri, 7 Apr 2017 19:22:17 -0400 Subject: [PATCH] Redo #23418 (#23425) * Check for provider values inside check_args of respective network code * Partial revert of b9ee5aa The no_log change is okay, but take out the action result munging --- lib/ansible/module_utils/dellos10.py | 7 ++++++- lib/ansible/module_utils/dellos6.py | 7 ++++++- lib/ansible/module_utils/dellos9.py | 7 ++++++- lib/ansible/module_utils/eos.py | 7 ++++++- lib/ansible/module_utils/ios.py | 7 ++++++- lib/ansible/module_utils/iosxr.py | 7 ++++++- lib/ansible/module_utils/junos.py | 7 ++++++- lib/ansible/module_utils/nxos.py | 7 ++++++- lib/ansible/module_utils/sros.py | 7 ++++++- lib/ansible/module_utils/vyos.py | 7 ++++++- lib/ansible/plugins/action/dellos10.py | 6 ------ lib/ansible/plugins/action/dellos6.py | 6 ------ lib/ansible/plugins/action/dellos9.py | 6 ------ lib/ansible/plugins/action/eos.py | 6 ------ lib/ansible/plugins/action/ios.py | 6 ------ lib/ansible/plugins/action/iosxr.py | 6 ------ lib/ansible/plugins/action/junos.py | 6 ------ lib/ansible/plugins/action/nxos.py | 8 -------- lib/ansible/plugins/action/sros.py | 6 ------ lib/ansible/plugins/action/vyos.py | 6 ------ 20 files changed, 60 insertions(+), 72 deletions(-) diff --git a/lib/ansible/module_utils/dellos10.py b/lib/ansible/module_utils/dellos10.py index db2c5eedbd0..e751e74382e 100644 --- a/lib/ansible/module_utils/dellos10.py +++ b/lib/ansible/module_utils/dellos10.py @@ -31,7 +31,7 @@ # import re -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command from ansible.module_utils.netcfg import NetworkConfig,ConfigLine @@ -63,6 +63,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('auth_pass', 'password'): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def get_config(module, flags=[]): cmd = 'show running-config ' diff --git a/lib/ansible/module_utils/dellos6.py b/lib/ansible/module_utils/dellos6.py index f67d2ed839a..53c5f0bf48a 100644 --- a/lib/ansible/module_utils/dellos6.py +++ b/lib/ansible/module_utils/dellos6.py @@ -30,7 +30,7 @@ # import re -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command from ansible.module_utils.netcfg import NetworkConfig, ConfigLine, ignore_line, DEFAULT_COMMENT_TOKENS @@ -63,6 +63,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('auth_pass', 'password'): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def get_config(module, flags=[]): cmd = 'show running-config ' diff --git a/lib/ansible/module_utils/dellos9.py b/lib/ansible/module_utils/dellos9.py index 9ad4977dde8..0af653d97ca 100644 --- a/lib/ansible/module_utils/dellos9.py +++ b/lib/ansible/module_utils/dellos9.py @@ -31,7 +31,7 @@ # import re -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command from ansible.module_utils.netcfg import NetworkConfig,ConfigLine @@ -63,6 +63,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('auth_pass', 'password'): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def get_config(module, flags=[]): cmd = 'show running-config ' diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py index 0c8555cdf9c..21f8e05dc44 100644 --- a/lib/ansible/module_utils/eos.py +++ b/lib/ansible/module_utils/eos.py @@ -30,7 +30,7 @@ import os import time -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.connection import exec_command from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.six import iteritems @@ -64,6 +64,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('auth_pass', 'password'): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def load_params(module): provider = module.params.get('provider') or dict() for key, value in iteritems(provider): diff --git a/lib/ansible/module_utils/ios.py b/lib/ansible/module_utils/ios.py index 21df837d1ca..128757c75a8 100644 --- a/lib/ansible/module_utils/ios.py +++ b/lib/ansible/module_utils/ios.py @@ -25,7 +25,7 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command @@ -50,6 +50,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('auth_pass', 'password'): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def get_defaults_flag(module): rc, out, err = exec_command(module, 'show running-config ?') diff --git a/lib/ansible/module_utils/iosxr.py b/lib/ansible/module_utils/iosxr.py index 570b904b34d..043da2e83d6 100644 --- a/lib/ansible/module_utils/iosxr.py +++ b/lib/ansible/module_utils/iosxr.py @@ -26,7 +26,7 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command @@ -49,6 +49,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('password',): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def get_config(module, flags=[]): cmd = 'show running-config ' cmd += ' '.join(flags) diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py index 21fed91bd4c..436f8793ed1 100644 --- a/lib/ansible/module_utils/junos.py +++ b/lib/ansible/module_utils/junos.py @@ -20,7 +20,7 @@ from contextlib import contextmanager from xml.etree.ElementTree import Element, SubElement -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.netconf import send_request, children from ansible.module_utils.netconf import discard_changes, validate from ansible.module_utils.six import string_types @@ -48,6 +48,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('password',): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def _validate_rollback_id(module, value): try: if not 0 <= int(value) <= 49: diff --git a/lib/ansible/module_utils/nxos.py b/lib/ansible/module_utils/nxos.py index 6ddbf8826ae..8bea8f35971 100644 --- a/lib/ansible/module_utils/nxos.py +++ b/lib/ansible/module_utils/nxos.py @@ -30,7 +30,7 @@ import re import collections -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command from ansible.module_utils.six import iteritems @@ -61,6 +61,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('password',): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def load_params(module): provider = module.params.get('provider') or dict() for key, value in iteritems(provider): diff --git a/lib/ansible/module_utils/sros.py b/lib/ansible/module_utils/sros.py index bbb8679cd0f..6f374e444fd 100644 --- a/lib/ansible/module_utils/sros.py +++ b/lib/ansible/module_utils/sros.py @@ -28,7 +28,7 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command @@ -51,6 +51,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('password',): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def get_config(module, flags=[]): cmd = 'admin display-config ' cmd += ' '.join(flags) diff --git a/lib/ansible/module_utils/vyos.py b/lib/ansible/module_utils/vyos.py index bc86c464ee8..54ee4a3985f 100644 --- a/lib/ansible/module_utils/vyos.py +++ b/lib/ansible/module_utils/vyos.py @@ -25,7 +25,7 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.network_common import to_list from ansible.module_utils.connection import exec_command @@ -50,6 +50,11 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) + if provider: + for param in ('password',): + if provider.get(param): + module.no_log_values.update(return_values(provider[param])) + def get_config(module, target='commands'): cmd = ' '.join(['show configuration', target]) diff --git a/lib/ansible/plugins/action/dellos10.py b/lib/ansible/plugins/action/dellos10.py index 102ca6feae1..2ce029fb278 100644 --- a/lib/ansible/plugins/action/dellos10.py +++ b/lib/ansible/plugins/action/dellos10.py @@ -93,12 +93,6 @@ class ActionModule(_ActionModule): self._play_context.become_method = None result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/dellos6.py b/lib/ansible/plugins/action/dellos6.py index dfbc349afe0..722ad31c051 100644 --- a/lib/ansible/plugins/action/dellos6.py +++ b/lib/ansible/plugins/action/dellos6.py @@ -89,12 +89,6 @@ class ActionModule(_ActionModule): self._play_context.become_method = None result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/dellos9.py b/lib/ansible/plugins/action/dellos9.py index 6222da4f214..36136e1699b 100644 --- a/lib/ansible/plugins/action/dellos9.py +++ b/lib/ansible/plugins/action/dellos9.py @@ -93,12 +93,6 @@ class ActionModule(_ActionModule): self._play_context.become_method = None result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/eos.py b/lib/ansible/plugins/action/eos.py index f3cd2dfe417..3a8268e831d 100644 --- a/lib/ansible/plugins/action/eos.py +++ b/lib/ansible/plugins/action/eos.py @@ -118,12 +118,6 @@ class ActionModule(_ActionModule): self._task.args['provider'] = provider result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/ios.py b/lib/ansible/plugins/action/ios.py index 0a1cafbaf5a..e4d721c2dec 100644 --- a/lib/ansible/plugins/action/ios.py +++ b/lib/ansible/plugins/action/ios.py @@ -88,12 +88,6 @@ class ActionModule(_ActionModule): self._play_context.become_method = None result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/iosxr.py b/lib/ansible/plugins/action/iosxr.py index b5e1daa0ad8..661b2d37e36 100644 --- a/lib/ansible/plugins/action/iosxr.py +++ b/lib/ansible/plugins/action/iosxr.py @@ -83,12 +83,6 @@ class ActionModule(_ActionModule): task_vars['ansible_socket'] = socket_path result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/junos.py b/lib/ansible/plugins/action/junos.py index 5dae42f2c0e..06078a0ba71 100644 --- a/lib/ansible/plugins/action/junos.py +++ b/lib/ansible/plugins/action/junos.py @@ -103,12 +103,6 @@ class ActionModule(_ActionModule): task_vars['ansible_socket'] = socket_path result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py index f23c520a8ee..9bdc508bb8b 100644 --- a/lib/ansible/plugins/action/nxos.py +++ b/lib/ansible/plugins/action/nxos.py @@ -120,12 +120,6 @@ class ActionModule(_ActionModule): self._task.args['transport'] = transport result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): @@ -160,5 +154,3 @@ class ActionModule(_ActionModule): return strategy(*args, **kwargs) except AnsibleFallbackNotFound: pass - - diff --git a/lib/ansible/plugins/action/sros.py b/lib/ansible/plugins/action/sros.py index 9d3a31fba6a..3a373052440 100644 --- a/lib/ansible/plugins/action/sros.py +++ b/lib/ansible/plugins/action/sros.py @@ -79,12 +79,6 @@ class ActionModule(_ActionModule): task_vars['ansible_socket'] = socket_path result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context): diff --git a/lib/ansible/plugins/action/vyos.py b/lib/ansible/plugins/action/vyos.py index 0ee7dcd092a..2ac1218abea 100644 --- a/lib/ansible/plugins/action/vyos.py +++ b/lib/ansible/plugins/action/vyos.py @@ -81,12 +81,6 @@ class ActionModule(_ActionModule): task_vars['ansible_socket'] = socket_path result = super(ActionModule, self).run(tmp, task_vars) - - try: - del result['invocation']['module_args']['provider'] - except KeyError: - pass - return result def _get_socket_path(self, play_context):