I want to change one line of my code in file /var/www/kibana/config.js during installation from
elasticsearch: \"http://\"+window.location.hostname+\":9200\"
It’s a string already; you don’t have to (and can’t, as seen here) escape colons inside it.
line="elasticsearch: \" {{ elasticsearch_URL }}:{{ elasticsearch_port }} \" "