Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape Single Quotes Ansible 2.1

Using 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\"'," 

That commands works but adds

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

Please how do i remove the single quote, so i can have

"rpc_json": "127.0.0.1:54321",
like image 256
dev Avatar asked Oct 25 '25 03:10

dev


1 Answers

It is more bash question than ansible:

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",'\'

In '\'' first ' closes string, then \' glues escaped single quote, then ' starts next string to be glued.

like image 128
Konstantin Suvorov Avatar answered Oct 27 '25 20:10

Konstantin Suvorov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!