问题原文
原帖链接 · Nik · CC BY-SA 3.0
I'm new to ansible, however I was able to successfully use the blockinfile function. However I can't figure out how to prevent markers from being inserted. I read the documentation but it didn't appear to describe it.
This is what shows up in every file that blockinfile writes to.
# BEGIN ANSIBLE MANAGED BLOCK
# END ANSIBLE MANAGED BLOCK
已采纳解答
原帖链接 · udondan · CC BY-SA 4.0
The markers are actually used to identify the block.
That means if you remove the markers, blockinfile will no longer be able to identify the block, which will result in the module to add the block to the file every time you run the task.
So the markers before and after the written block are a requirement by the module and cannot be removed.
If this is a one-time playbook that will never be executed again you could run the lineinfile module with the state: absent option afterwards.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
