Only check whether a line present in a file (ansible)

Question:

In ansible, I need to check whether a particular line present in a file or not. Basically, I need to convert the following command to an ansible task. My goal is to only check.

Answer:


Note: Older Ansible versions need to use always_run: yes instead of check_mode: no.

Leave a Reply