diff options
author | Ricardo Carrillo Cruz <ricardo.carrillo.cruz@gmail.com> | 2017-03-28 10:20:52 +0200 |
---|---|---|
committer | Ricardo Carrillo Cruz <ricardo.carrillo.cruz@gmail.com> | 2017-03-29 22:53:14 +0200 |
commit | 664b27aaf0c820647b704c6d39af4449dbbc2e44 (patch) | |
tree | 62f8f6de717eb8e96f799a1b2a9524f6e5ebf445 /lib/ansible/module_utils | |
parent | 3859551eb328339c17645cab4cc8ad2a0c70f145 (diff) | |
download | ansible-664b27aaf0c820647b704c6d39af4449dbbc2e44.tar.gz |
Introspect flag to use on 'show run' when using defaults in ios_config (#22903)
When the ios_config module has 'defaults' param it runs in the device the command
'show running-config all' but 'all' may not be available in older devices.
This change makes introspection by using the help command and run 'full' in case
'all' is not available.
Fixes #22747
Diffstat (limited to 'lib/ansible/module_utils')
-rw-r--r-- | lib/ansible/module_utils/ios.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ansible/module_utils/ios.py b/lib/ansible/module_utils/ios.py index 38412f6eaf..480c8f9880 100644 --- a/lib/ansible/module_utils/ios.py +++ b/lib/ansible/module_utils/ios.py @@ -50,6 +50,16 @@ def check_args(module, warnings): warnings.append('argument %s has been deprecated and will be ' 'removed in a future version' % key) +def get_defaults_flag(module): + rc, out, err = exec_command(module, 'show running-config ?') + + commands = set() + for line in out.splitlines(): + if line: + commands.add(line.strip().split()[0]) + + return 'all' if 'all' in commands else 'full' + def get_config(module, flags=[]): cmd = 'show running-config ' cmd += ' '.join(flags) |