Strong double quotes and single quotes

I would like to insert the nrpe command in nrpe.cfg with this obscure command

check_tomcat_threads.pl -H localhost -p 30011 -C '"http-bio-30011"' -w 200 -c 50

But the problem is "and"

To set this line in the nrpe.cfg file, use the command

 - { regexp: '^command\[SERVICE_tomcat_pi_Threads\]', line: "command[SERVICE_tomcat_Threads_pi]=/appiu/monitoring/check_tomcat_threads.pl -H localhost -p 30011 -C '\"http-bio-30011\"' -w 200 -c 50" }

but the result in the nrpe.cfg file is

...-C http-bio-30011..

If I use '' \ 'http-bio-30011 \ "' 'in ansible script

the result in nrpe.cfg is

...-C "http-bio-30011"... 

How can I escape single quotes and double quotes to get this -C '"http-bio-30011"'?

Greetings Georg

+4
source share
1 answer

This is a bug in the module lineinfile.

YAML ( , ). " \ :

line: "command[SERVICE_tomcat_Threads_pi]=/appiu/monitoring/check_tomcat_threads.pl -H localhost -p 30011 -C '\"http-bio-30011\"' -w 200 -c 50"

, :

line: 'command[SERVICE_tomcat_Threads_pi]=/appiu/monitoring/check_tomcat_threads.pl -H localhost -p 30011 -C \''"http-bio-30011"\'' -w 200 -c 50'
+5

Source: https://habr.com/ru/post/1610581/


All Articles