正则表达式 – 如何在可复制的YAML文件中的字符串中转义冒号?
发布时间:2020-12-14 06:34:00 所属栏目:百科 来源:网络整理
导读:我想在安装过程中更改文件/var/www/kibana/config.js中的一行代码 elasticsearch: "http://"+window.location.hostname+":9200" 至 elasticsearch: "http://192.168.1.200:9200" 在这里我试图使用lineinfile做如下所示 - name: Comment out elasticsearch th
我想在安装过程中更改文件/var/www/kibana/config.js中的一行代码
elasticsearch: "http://"+window.location.hostname+":9200" 至 elasticsearch: "http://192.168.1.200:9200" 在这里我试图使用lineinfile做如下所示 - 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 我已将{{elasticsearch_URL}}和{{elasticsearch_port}}的变量分别设置为http://192.168.1.200和9200。 这是我遇到的错误信息: 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 }} " " ^
您需要将整个行包含在“,其中:出现。
lineinfile: 'dest=/var/www/kibana/config.js backrefs=true regexp="(elasticsearch.* "http.*)$" line="elasticsearch: {{ elasticsearch_URL }}:{{ elasticsearch_port }} " state=present' 请看这些页面: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |