Ansible:模块命令

时间:2018-12-18 09:18:04

标签: ansible

我想用Ansible执行此命令:

grep -v -P "^#" /etc/snort/community-sid-msg.map > /etc/snort/community-sid-msg-no-comments.map

我想知道我的Ansible代码中必须包含哪些字符:

- name: create file
  command: "grep -v -P "^#" /etc/snort/community-sid-msg.map > /etc/snort/community-sid-msg-no-comments.map"

1 个答案:

答案 0 :(得分:0)

使用 copy replace 模块会更好吗?

- copy:
    src: /etc/snort/community-sid-msg.map
    dest: etc/snort/community-sid-msg-no-comments.map
- replace:
    path: etc/snort/community-sid-msg-no-comments.map
    regexp: "^#[^\n]*\n"