Escape Single Quotes Ansible 2.1

时间:2016-07-28 15:35:48

标签: ansible ansible-2.x

使用Ansible 2.1,

ansible all -i 127.0.0.1, -m lineinfile   -a    "dest=/etc/engine/engine.json state=present regexp=\"rpc_json\" line='\"rpc_json\": \"127.0.0.1:54321\"'," 

该命令有效但添加了

'"rpc_json": "127.0.0.1:54321"',

请如何删除单引号,以便我可以

"rpc_json": "127.0.0.1:54321",

1 个答案:

答案 0 :(得分:1)

比ansible更多的是bash问题:

ansible all -i 127.0.0.1, -m lineinfile -a 'dest=/etc/engine/engine.json state=present regexp=rpc_json line='\''"rpc_json": "127.0.0.1:54321",'\'

'\''首先'关闭字符串,然后\'胶水转义单引号,然后'开始下一个要粘贴的字符串。