blockinfile, delete the rest

12 views
Skip to first unread message

needabettername

unread,
Mar 30, 2021, 5:42:46 PM3/30/21
to Ansible Project
Hi,

I'd like to edit a file using block in file and delete anything in the file that isn't in that block, in an idempotent way i,e, not just deleting the file first.

I suspect I should be using a template here but partly want to scratch the itch of whether it's possible, is there a reasonable way?

Dick Visser

unread,
Mar 31, 2021, 12:45:00 AM3/31/21
to ansible...@googlegroups.com
On Tue, 30 Mar 2021 at 23:42, needabettername <alls...@gmail.com> wrote:
Hi,

I'd like to edit a file using block in file and delete anything in the file that isn't in that block, in an idempotent way i,e, not just deleting the file first.


This would have exactly the same results as using the template module, only harder to do.


I suspect I should be using a template here but partly want to scratch the itch of whether it's possible, is there a reasonable way?

You probably should. Put differently, why would you not use the template module?


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/645c4a3d-69a9-40d0-8c0e-5cd8a1833f0cn%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Reply all
Reply to author
Forward
0 new messages