mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
update ios_command module return values
This minor change updates the return values and doc string for the ios_command module to be consistent with other network modules
This commit is contained in:
parent
a160d5426d
commit
13793d7b95
1 changed files with 12 additions and 17 deletions
|
@ -76,34 +76,33 @@ EXAMPLES = """
|
||||||
commands:
|
commands:
|
||||||
- show version
|
- show version
|
||||||
waitfor:
|
waitfor:
|
||||||
- "result[0] contains 4.15.0F"
|
- "result[0] contains IOS"
|
||||||
|
|
||||||
- ios_command:
|
- ios_command:
|
||||||
commands:
|
commands:
|
||||||
- show version
|
- show version
|
||||||
- show interfaces
|
- show interfaces
|
||||||
- show version
|
|
||||||
waitfor:
|
|
||||||
- "result[2] contains '4.15.0F'"
|
|
||||||
- "result[1].interfaces.Management1.interfaceAddress[0].primaryIp.maskLen eq 24"
|
|
||||||
- "result[0].modelName == 'vios'"
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
stdout:
|
||||||
result:
|
|
||||||
description: the set of responses from the commands
|
description: the set of responses from the commands
|
||||||
returned: always
|
returned: always
|
||||||
type: list
|
type: list
|
||||||
sample: ['...', '...']
|
sample: ['...', '...']
|
||||||
|
|
||||||
failed_conditionals:
|
stdout_lines:
|
||||||
|
description: The value of stdout split into a list
|
||||||
|
returned: always
|
||||||
|
type: list
|
||||||
|
sample: [['...', '...'], ['...'], ['...']]
|
||||||
|
|
||||||
|
failed_conditions:
|
||||||
description: the conditionals that failed
|
description: the conditionals that failed
|
||||||
retured: failed
|
retured: failed
|
||||||
type: list
|
type: list
|
||||||
sample: ['...', '...']
|
sample: ['...', '...']
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
@ -145,15 +144,11 @@ def main():
|
||||||
except AttributeError, exc:
|
except AttributeError, exc:
|
||||||
module.fail_json(msg=exc.message)
|
module.fail_json(msg=exc.message)
|
||||||
|
|
||||||
result = dict(changed=False, result=list())
|
result = dict(changed=False)
|
||||||
|
|
||||||
while retries > 0:
|
while retries > 0:
|
||||||
response = module.execute(commands)
|
response = module.execute(commands)
|
||||||
result['result'] = response
|
result['stdout'] = response
|
||||||
|
|
||||||
for index, cmd in enumerate(commands):
|
|
||||||
if cmd.endswith('json'):
|
|
||||||
response[index] = json.loads(response[index])
|
|
||||||
|
|
||||||
for item in list(queue):
|
for item in list(queue):
|
||||||
if item(response):
|
if item(response):
|
||||||
|
@ -168,9 +163,9 @@ def main():
|
||||||
failed_conditions = [item.raw for item in queue]
|
failed_conditions = [item.raw for item in queue]
|
||||||
module.fail_json(msg='timeout waiting for value', failed_conditions=failed_conditions)
|
module.fail_json(msg='timeout waiting for value', failed_conditions=failed_conditions)
|
||||||
|
|
||||||
|
result['stdout_lines'] = list(to_lines(result['stdout']))
|
||||||
return module.exit_json(**result)
|
return module.exit_json(**result)
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.urls import *
|
from ansible.module_utils.urls import *
|
||||||
from ansible.module_utils.shell import *
|
from ansible.module_utils.shell import *
|
||||||
|
|
Loading…
Reference in a new issue