# Match content, modify the content if the match is successful, add content if the match fails
- name: add or modify a line
lineinfile:
dest: /tmp/test.txt
regex: '^What needs to be replaced'
line: 'new content'
# Match content, modify the content if the match is successful, add content if the match fails
- name: add or modify a line
lineinfile:
dest: /tmp/test.txt
regex: '^What needs to be replaced'
line: 'new content'