How can escape colon in a string within an Ansible YAML file?

前端 未结 5 1919
無奈伤痛
無奈伤痛 2020-12-03 06:47

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


        
5条回答
  •  孤街浪徒
    2020-12-03 07:29

    foo=bar is the more suitable format for a one-line directive, but as you're already spanning several lines with your parameters anyway, just change the = to :, and it won't fuss about having a colon in your string.

    - 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
    

提交回复
热议问题