Skip to content

Commit

Permalink
ios_bgp: fixes ansible#57666 (ansible#57667)
Browse files Browse the repository at this point in the history
* ios_bgp: fixes ansible#57666

* ios_bgp: add integration tests
  • Loading branch information
hexdump0x0200 authored and NilashishC committed Oct 18, 2019
1 parent 04252cf commit cb0ee51
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def render(self, config=None):
existing_as = None
if config:
match = re.search(r'router bgp (\d+)', config, re.M)
existing_as = match.group(1)
if match:
existing_as = match.group(1)

operation = self.params['operation']

Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/network/ios/ios_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def main():
supports_check_mode=True)

try:
result = module.edit_config(config_filter='| section bgp')
result = module.edit_config(config_filter='| section ^router bgp')
except Exception as exc:
module.fail_json(msg=to_text(exc))

Expand Down
56 changes: 56 additions & 0 deletions test/integration/targets/ios_bgp/tests/cli/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,62 @@
ignore_errors: yes

- block:

- name: Add fake config with 'bgp' string
ios_config:
match: none
replace: block
lines:
- "no ip access-list extended BGP_ACL"
- "ip access-list extended BGP_ACL"
- "permit tcp any any eq bgp"

- name: Try delete fake bgp config
register: result
ios_bgp:
operation: delete

- assert:
that:
- 'result.changed == false'

- name: Clean fake config with 'bgp' string
ios_config:
match: none
replace: block
lines:
- "no ip access-list extended BGP_ACL"

- name: Add fake bgp-like config
ios_config:
match: none
replace: block
lines:
- "no ip access-list extended BGP_ACL_2"
- "ip access-list extended BGP_ACL_2"
- "remark router bgp 64496"
- "remark neighbor 192.0.2.10 remote-as 64496"
- "remark neighbor 192.0.2.10 shutdown"
- "remark address-family ipv4"
- "remark neighbor 192.0.2.10 activate"
- "remark exit-address-family"
- "permit tcp any any eq bgp"

- name: Try delete fake bgp-like config
register: result
ios_bgp:
operation: delete

- assert:
that:
- 'result.changed == false'

- name: Clean fake bgp-like config
ios_config:
match: none
replace: block
lines:
- "no ip access-list extended BGP_ACL_2"

- name: Configure BGP with AS 64496 and a router-id
ios_bgp: &config
Expand Down

0 comments on commit cb0ee51

Please sign in to comment.