title: How can escape colon in a string within an Ansible YAML file?
body: <p>I want to change one line of my code in file /var/www/kibana/config.js during installation from</p>
  
  <pre><code>elasticsearch: "http://"+window.location.hostname+":9200"
  </code></pre>
  
  <p>to</p>
  
  <pre><code>elasticsearch: "http://192.168.1.200:9200"
  </code></pre>
  
  <p>Here I tried to use lineinfile to do that as show below</p>
  
  <pre><code>- name: Comment out elasticsearch the config.js to ElasticSearch server
    lineinfile:
      dest=/var/www/kibana/config.js
      backrefs=true
      regexp="(elasticsearch.* \"http.*)$"
      line="elasticsearch\: \" {{ elasticsearch_URL }}:{{ elasticsearch_port }} \" "
      state=present
  </code></pre>
  
  <p>I have set variables of <code>{{elasticsearch_URL}}</code> and <code>{{elasticsearch_port}}</code> to <code>http://192.168.1.200</code> and <code>9200</code>, respectively.</p>
  
  <p>Here is the error message I met:</p>
  
  <pre><code>ERROR: Syntax Error while loading YAML script, /Users/shuoy/devops_workspace/ansible_work/logging-for-openstack/roles/kibana/tasks/Debian.yml
  Note: The error may actually appear before this position: line 29, column 25
  
  regexp="(elasticsearch.* \"http.*)$"
  line="elasticsearch\: \" {{ elasticsearch_URL }}:{{ elasticsearch_port }} \" "
                      ^
  </code></pre>