我想用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"
答案 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"