Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruchip16 committed May 16, 2024
1 parent 6eccd0e commit 01329ab
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 4 deletions.
85 changes: 83 additions & 2 deletions plugins/modules/ios_vrf_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@
# route-target import 1.12.3.4:200
# vrf definition VRF7
#
- name: Delete the provided configuration
- name: Delete the provided configuration when config is given
hosts: ios
gather_facts: false
tasks:
- name: Delete the provided configuration
- name: Delete the provided configuration when config is given
cisco.ios.ios_vrf_global:
config:
vrfs:
Expand Down Expand Up @@ -453,6 +453,38 @@
# vrf definition VRF6
# vrf definition VRF7
#
- name: Delete the provided configuration when config is empty
hosts: ios
gather_facts: false
tasks:
- name: Delete the provided configuration when config is empty
cisco.ios.ios_vrf_global:
config:
state: deleted
# Task output
# -------------
# commands:
# - vrf definition VRF2
# - vrf definition VRF6
# - no description VRF6 description
# - no ipv4 multicast multitopology
# - no ipv6 multicast multitopology
# - no rd 6:7
# - no route-target export 3.1.3.4:400
# - no route-target import 1.12.3.4:200
# - no vnet tag 500
# - no vpn id 4:5
# - vrf definition VRF7
#
# After state:
# -------------
# admin#show running-config | section ^vrf
# vrf definition VRF2
# vrf definition VRF6
# vrf definition VRF7
#
#
# Using purged
# Before state:
# -------------
Expand Down Expand Up @@ -558,6 +590,55 @@
# rd 1.2.3.4:500
"""

RETURN = """
before:
description: The configuration prior to the module execution.
returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
type: dict
sample: >
This output will always be in the same format as the
module argspec.
after:
description: The resulting configuration after module execution.
returned: when changed
type: dict
sample: >
This output will always be in the same format as the
module argspec.
commands:
description: The set of commands pushed to the remote device.
returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
type: list
sample:
- "vrf definition test"
- "description This is a test VRF"
- "rd: 2:3"
rendered:
description: The provided configuration in the task rendered in device-native format (offline).
returned: when I(state) is C(rendered)
type: list
sample:
- "vrf definition management"
- "description This is a test VRF"
- "rd: 2:3"
- "route-target export 190.0.2.3:400"
- "route-target import 190.0.2.1:300"
gathered:
description: Facts about the network resource gathered from the remote device as structured data.
returned: when I(state) is C(gathered)
type: list
sample: >
This output will always be in the same format as the
module argspec.
parsed:
description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
returned: when I(state) is C(parsed)
type: list
sample: >
This output will always be in the same format as the
module argspec.
"""


from ansible.module_utils.basic import AnsibleModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
that:
- deleted['after'] == result['after']

- name: Delete provided BGP global (idempotent)
- name: Delete provided VRF global (idempotent)
register: result
cisco.ios.ios_vrf_global: *id001
- name: Assert that the previous task was idempotent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
that:
- result.msg == 'value of config parameter must not be empty for state replaced'

- name: Overridden with empty configuration should give appropriate error message
register: result
ignore_errors: true
cisco.ios.ios_vrf_global:
config:
state: overridden

- ansible.builtin.assert:
that:
- result.msg == 'value of config parameter must not be empty for state overridden'

- name: Rendered with empty configuration should give appropriate error message
register: result
ignore_errors: true
Expand All @@ -46,5 +57,16 @@
that:
- result.msg == 'value of running_config parameter must not be empty for state parsed'

- name: Purged with empty configuration should give appropriate error message
register: result
ignore_errors: true
cisco.ios.ios_vrf_global:
config:
state: purged

- ansible.builtin.assert:
that:
- result.msg == 'value of running_config parameter must not be empty for state purged'

- ansible.builtin.debug:
msg: END ios_vrf_global empty_config integration tests on connection={{ ansible_connection }}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
that:
- replaced['after'] == result['after']

- name: Replaced provided BGP global configuration (idempotent)
- name: Replaced provided VRF global configuration (idempotent)
register: result
cisco.ios.ios_vrf_global: *id001
- name: Assert that task was idempotent
Expand Down

0 comments on commit 01329ab

Please sign in to comment.