with blockinfile module, I'm looking for option to check the entries whether its present or not! if not then entries have to be added by play.

Hello,

Can someone please help to solve my request?

with blockinfile module, I’m looking for option to check the entries whether its present or not! if not then entries have to be added by play.

As per below my playbook, its working partially, like its appending even if the entries are already present but actually i’m looking that play should ignore if already entries are exists and incase not present then it should added.

Playbook:-
cat resolv_add.yml

Hello,

Can someone please help to solve my request?

with blockinfile module, I'm looking for option to check the entries
whether its present or not! if not then entries have to be added by play.

As per below my playbook, its working partially, like its appending even if
the entries are already present but actually i'm looking that play should
ignore if already entries are exists and incase not present then it should
added.

My guess is that it is finding the empty string marker at BOF and finding nothing between the zero length marker and itself, this adding the block unconditionally. You will have more luck with a non empty marker.

V/r,
James Cassell

Thank you James, its working fine.

Thanks,
Deepan M