regex cisco接口父级和子级

时间:2018-12-03 04:26:30

标签: regex ansible

以下内容:

interface Vlan10
  ip address 10.17.8.17/30
  ip ospf message-digest-key 1 md5 3 xsdssdsdjhsd
  ip router ospf 14 area 0.0.0.0
  no shutdown
interface Vlan140
  vrf member Automation
  ip address 10.75.54.14/30
  ip router eigrp 1
  no shutdown
interface Vlan150
  vrf member Automation
  ip address 10.15.24.29/30
  ip router eigrp 1
  no shutdown
interface Vlan24
  ip address 10.17.54.50/30
  ip router eigrp 10
  no shutdown
interface Vlan101
  ip address 10.11.10.2/24
  ip ospf cost 1000
  ip router ospf 14 area 0.0.0.1
  no shutdown
interface Vlan1221
  ip address 10.41.12.4/30
  ip ospf cost 10
  ip router ospf 1 area 0.0.0.0
  no shutdown
interface Vlan122
  ip address 10.14.2.53/30
  ip ospf cost 9
  ip router ospf 1 area 0.0.0.0
  no shutdown
interface Vlan1258
  vrf member Automation
  ip address 10.11.1.23/30
  ip router eigrp 1
  no shutdown
interface port-channel16
  switchport
  switchport mode trunk
  switchport trunk allowed vlan 10,15,121

需要帮助捕获ip router eigrpip address(它们是子名称和接口名称(VLAN,以太网)等),最后对包含所有这三个接口的所有接口重复此过程。

预期的组合是接口名称,ip地址,每个接口的eigrp编号,并在所有接口上重复相同的内容。

只需添加即可获取具有eigrp的接口。

试过这个但没用-> ^ interface(\ S +)?(?:\ s +)?(?:( ip地址)(\ S +))?(?:( ?: ip router eigrp)( \ S +))

1 个答案:

答案 0 :(得分:0)

想出了一种基于路由器eigrp或ospf进行后置过滤的方法,然后使用ansible进行遍历。

^ interface(\ S +)(?:\ n \ s {2}。(?<= eigrp)