mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
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
This commit is contained in:
parent
495a1340a6
commit
a5b12ff269
2 changed files with 12 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue