2016-07-28 134 views
0

使用Ansible 2.1,逃逸單引號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

這比問題更多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",'\' 

'\''第一個'關閉字符串,然後\'膠水溢出單引號,然後'開始下一個要粘的字符串。