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

时间:2019-05-24 08:59:26

标签: shell ansible

我正在尝试在json文件中找到某个键​​值对,但ansible似乎不喜欢:字符... 我尝试将所有角色转义都没有成功...对我做错的事情有任何想法吗?

- 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

1 个答案:

答案 0 :(得分:1)

引用整个shell行:

 shell: 'cat PATH/dummy_file.file | grep "\"KEY\": \"VAL\""'
相关问题