cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
682
Views
3
Helpful
6
Replies

Ansible: - ios_config sub configuration level

Netmart
Level 1
Level 1

 

 Hello,

I am wondering about the syntax when adding or removing parameters for example removing a redistribution list under the BGP Process / Address Family IP4 - see example below.

Thanks,


  tasks:

     - name: no router eigrp

       ios_config:

          commands:

              - no router eigrp 10

              - no snmp-server enable traps eigrp

 

Hello,

I am wondering about the syntax when adding or removing parameters for example removing a redistribution list under the BGP Process / Address Family IP4 - see example below.

Thanks,


  tasks:

     - name: bgp

       ios_config:

          commands

              - router bgp 65100

                   address-family ipv4

                   no redistribute eigrp 15 route-map EIGRP-2-BGP

        become: true

       register: output

     

2 Accepted Solutions

Accepted Solutions

Marcel Zehnder
Spotlight
Spotlight

Try to define your entire address-familiy configuration using  cisco.ios.ios_bgp_address_family and use "replaced" as the state.

View solution in original post

Hello Marcel,

To me the following solution eventually worked out:

 

     - name: "BGP: no EIGRP redist route map"

       ios_config:

         lines:

              - no redistribute eigrp 10 route-map EIGRP-2-BGP

         parents:

              - router bgp 65411

              - address-family ipv4  

       become: true

       register: output2

View solution in original post

6 Replies 6

M02@rt37
VIP
VIP

Hello @Netmart,

Neighbor is missing I think ; examplewith neighbor 192.168.1.1:

- name: bgp configuration
ios_config:
lines:
- router bgp 65100
- neighbor 192.168.1.1 remote-as 65000
- neighbor 192.168.1.1 description Neighbor_to_AS_65000
- address-family ipv4
- no redistribute eigrp 15 route-map EIGRP-2-BGP
become: true
register: output

 

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.

Sorry this does not work:

TASK [BGP: No EIGRP redist route map] ********************************************************************************************************************************************************************************************
fatal: [*******]: FAILED! => {"changed": false, "msg": "dictionary requested, could not parse JSON or key=value"}

Marcel Zehnder
Spotlight
Spotlight

You can also try using the cisco.ios.ios_bgp_address_family module (https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_bgp_address_family_module.html#ansible-collections-cisco-ios-ios-bgp-address-family-module

    - name: "No EIGRP redist route map"
      cisco.ios.ios_bgp_address_family:
        config:
          as_number: 65100
          address_family:
            - afi: ipv4
              safi: unicast
              redistribute:
                - eigrp:
                    as_number: 15
                    route_map: EIGRP-2-BGP
        state: deleted

 

Hello Marcel,

If I am trying the following it does delete all neighbor configs und address-family ip4 entries.

The idea was to only delete the route map entry "RM-EIGRP-2-BGP"

 

  tasks:

     

     - name: "BGP: No EIGRP redist route map"

       cisco.ios.ios_bgp_address_family:

        config:

          as_number: 65100

          address_family:

            - afi: ipv4

              redistribute:

                - eigrp:

                    as_number: 10

                    route_map: RM-EIGRP-2-BGP

        state: deleted

       

       become: true

       register: output1

 

 

Extract of result:

},
"changed": true,
"commands": [
"router bgp 65411",
"no address-family ipv4"
],
"failed": false

Marcel Zehnder
Spotlight
Spotlight

Try to define your entire address-familiy configuration using  cisco.ios.ios_bgp_address_family and use "replaced" as the state.

Hello Marcel,

To me the following solution eventually worked out:

 

     - name: "BGP: no EIGRP redist route map"

       ios_config:

         lines:

              - no redistribute eigrp 10 route-map EIGRP-2-BGP

         parents:

              - router bgp 65411

              - address-family ipv4  

       become: true

       register: output2