首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ansible -删除行

Ansible -删除行
EN

Stack Overflow用户
提问于 2019-12-09 20:55:34
回答 2查看 51关注 0票数 0

我正在尝试从文件中删除一行。如下所示:

代码语言:javascript
复制
  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']

该文件如下所示:

代码语言:javascript
复制
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

但是,它不会删除该行。我是不是做错了什么?

谢谢,

EN

回答 2

Stack Overflow用户

发布于 2019-12-09 21:54:16

您的正则表达式不匹配。

尝试:

regexp: 'Cryptocheck.*

票数 0
EN

Stack Overflow用户

发布于 2019-12-10 03:46:44

已使用delegate_to: localhost解决此问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59249372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档