我正在尝试从文件中删除一行。如下所示:
tasks:
- name: Remove Cryptochecksum Line
lineinfile:
path: '{{ snapshot_path }}/{{ snapshot_dir }}/configs/{{ inventory_hostname }}.cfg'
state: absent
regexp: '^Cryptochecksum'
when: inventory_hostname in groups['asa']该文件如下所示:
policy-map type inspect dns preset_dns_map
parameters
message-length maximum client auto
message-length maximum 512
no tcp-inspection
policy-map global_policy
class inspection_default
inspect ip-options
inspect netbios
inspect rtsp
inspect sunrpc
inspect tftp
inspect xdmcp
inspect icmp
inspect http
inspect dns preset_dns_map
inspect ftp
inspect h323 h225
inspect h323 ras
inspect rsh
inspect esmtp
inspect sqlnet
inspect sip
inspect skinny
policy-map type inspect dns migrated_dns_map_2
parameters
message-length maximum client auto
message-length maximum 512
no tcp-inspection
policy-map type inspect dns migrated_dns_map_1
parameters
message-length maximum client auto
message-length maximum 512
no tcp-inspection
!
service-policy global_policy global
prompt hostname context
no call-home reporting anonymous
call-home
profile CiscoTAC-1
no active
destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
destination address email callhome@cisco.com
profile License
destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
destination transport-method http
Cryptochecksum:7e3717e45276a214656372dc510fca38但是,它不会删除该行。我是不是做错了什么?
谢谢,
发布于 2019-12-09 21:54:16
您的正则表达式不匹配。
尝试:
regexp: 'Cryptocheck.*
发布于 2019-12-10 03:46:44
已使用delegate_to: localhost解决此问题。
https://stackoverflow.com/questions/59249372
复制相似问题