[英]Replace ansible line using lineinfile
Im working with ansible to change the line for https host 我正在与ansible一起更改https主机的行
---
- name: "change http to https"
lineinfile:
dest: "{{ install_dir }}/xx/abc-out.xml"
state: present
regexp: "<column name="PARAM_VALUE">http://host.com:42003</column>"
line: "<column name="PARAM_VALUE">https://host.com:42091</column>"
---
- name: Change line
vars_files:
- vars/conn.yml
become_user: "{{ app_user }}"
become: true
roles:
- { role: https-host }
It complain that the line is have a problem. 它抱怨线路有问题。 Can anyone help to point it out? 有人可以指出吗?
Try using single quotes like this - 尝试使用像这样的单引号-
regexp: '<column name="PARAM_VALUE">http://host.com:42003</column>'
line: '<column name="PARAM_VALUE">https://host.com:42091</column>'
Also, I see that the attributes dest
, state
, regexp
and line
are not indented correctly in the example you mentioned in your question. 另外,在您提到的示例中,我看到属性dest
, state
, regexp
和line
没有正确缩进。 It should look like this - 它看起来应该像这样-
---
- name: "change http to https"
lineinfile:
dest: "{{ install_dir }}/xx/abc-out.xml"
state: present
regexp: '<column name="PARAM_VALUE">http://host.com:42003</column>'
line: '<column name="PARAM_VALUE">https://host.com:42091</column>'
regexp: ' <column name="PARAM_VALUE">https://host.com:12360</column>'
As I mentioned in the comment. 正如我在评论中提到的。 The spacing and change to the single quote help. 间距和更改为单引号有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.