如果当前正在通过“no ip sla 46”运行,我需要删除路由器上的IP SLA配置,但是,如果路由器上当前不存在,则该剧本会失败。想法?
- name: Add IP SLA test
ios_config:
lines:
- udp-jitter 10.x.x.x source-ip {{ loopback }} codec g711ulaw
- tos 184
- tag Network Operation Center - G711ulaw EF VoIP
- frequency 180
parents: ip sla 46
before: no ip sla 46
结束使用ios_command检查当前的IP SLA配置并删除(如果存在)。
- name: Find current SLA 46 config
ios_command:
commands: 'show run | inc sla 46'
register: raw_sla_46
- set_fact:
sla_46: "{{ raw_sla_46.stdout[0] }}"
- name: Delete IP SLA 46 if present
ios_config:
lines:
- no ip sla 46
when: sla_46 == 'ip sla 46'
- name: Add IP SLA from Lo0 to DC
ios_config:
lines:
- udp-jitter 10.20.0.25 17000 source-ip {{ loopback }} codec g711ulaw
- tos 184
- tag Network Operation Center - CHA - G711ulaw EF VoIP
- frequency 180
parents: ip sla 46