From 9f64e446c6c2098e0490bd2712c146e01347debf Mon Sep 17 00:00:00 2001 From: David Newswanger Date: Wed, 19 Jul 2017 18:06:11 -0400 Subject: [PATCH] Fix #26918: IOS TypeError (#26999) Fix IOS TypeError * if flags are None, then ' '.join(flags) fails * fixed get_defaults_flag so that it returns a list, and ignores lines with white space Fixes #26918 --- lib/ansible/module_utils/ios.py | 6 +++--- lib/ansible/modules/network/ios/ios_config.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/module_utils/ios.py b/lib/ansible/module_utils/ios.py index d03c8f0600e..61b756cc5a7 100644 --- a/lib/ansible/module_utils/ios.py +++ b/lib/ansible/module_utils/ios.py @@ -71,13 +71,13 @@ def get_defaults_flag(module): commands = set() for line in out.splitlines(): - if line: + if line.strip(): commands.add(line.strip().split()[0]) if 'all' in commands: - return 'all' + return ['all'] else: - return 'full' + return ['full'] def get_config(module, flags=[]): diff --git a/lib/ansible/modules/network/ios/ios_config.py b/lib/ansible/modules/network/ios/ios_config.py index 22ddb17eb17..2ee15aaec7b 100644 --- a/lib/ansible/modules/network/ios/ios_config.py +++ b/lib/ansible/modules/network/ios/ios_config.py @@ -343,7 +343,7 @@ def get_running_config(module, current_config=None): if not module.params['defaults'] and current_config: contents, banners = extract_banners(current_config.config_text) else: - flags = get_defaults_flag(module) if module.params['defaults'] else None + flags = get_defaults_flag(module) if module.params['defaults'] else [] contents = get_config(module, flags=flags) contents, banners = extract_banners(contents) return NetworkConfig(indent=1, contents=contents), banners