简体   繁体   English

:使用ansible shell模块的grep命令中的字符错误

[英]: character error in a grep command using ansible shell module

Im trying to find a certain key value pair in a json file but ansible doesn't seem to like the : character... I tried escaping all the characters without success... any idea on what I'm doing wrong? 我试图在json文件中找到某个键​​值对,但是ansible似乎不喜欢:character ...我试图转义所有字符而没有成功...我在做什么错的任何想法?

- name: Check if file contains the entry KEY VAL
  shell: cat PATH/dummy_file.file | grep  "\"KEY\": \"VAL\""
  become: yes
  become_method: sudo
  failed_when: false
  register: cat_result

引用整个shell行:

 shell: 'cat PATH/dummy_file.file | grep "\"KEY\": \"VAL\""'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM