xxxxxxxxxx
- name: "Searching for a String"
lineinfile:
path: /home/myuser/file.txt
line: "string_to_find"
state: absent
check_mode: yes
# want to check only, so set changed explicitly to false
changed_when: false
register: presence
- debug: var=presence
- debug: msg="found"
when: presence.found
- debug: msg="not found"
when: not presence.found