We can use multi line scalar YAML syntax to get around this and have the text No
in the file contents.
Consider a simple text file sample.txt
as below:
works? Yes
I am using an example with lineinfile
(Linux), but should work similarly for Windows. A simple playbook with below tasks:
- set_fact:
var1: >
No
- lineinfile:
path: /tmp/sample.txt
line: "works? {{ var1 }}"
regexp: "^works"
When this playbook is run:
-works? Yes
+works? No
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…