# Blockinfile - how to delete text

**URL:** <https://forum.ansible.com/t/blockinfile-how-to-delete-text/25386>\
**Category:** Ansible Project\
**Created:** [August 31, 2017, 4:24pm UTC](https://forum.ansible.com/t/blockinfile-how-to-delete-text/25386 "2017-08-31T16:24:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 31, 2017, 4:24pm UTC](https://forum.ansible.com/t/blockinfile-how-to-delete-text/25386/1 "2017-08-31T16:24:14Z")

</div>

I have this text file and I was trying to delete some text that I had just added. Not sure how I would go about deleting

1. The entire text tree and the wrappers #BEGIN ANSIBLE MANAGED BLOCK

2. Just deleting the text tree

Can anyone explain? Thanks

The delete functionality is not functioning as expected

(ansible 2.3.0)

textfile -

> giraffe
> 
> This is my text to add
> 
> Noooooooooooooo
> 
> penguin
> 
> robot
> 
> #BEGIN ANSIBLE MANAGED BLOCK
> 
> tree
> 
> #BEGIN ANSIBLE MANAGED BLOCK

Tried the following playbook and it just deleted the last wrapper

Playbook

> * * *
> 
> - hosts: local
> 
> tasks:
> 
> - name: Use blockinfile
> 
> blockinfile:
> 
> path: /home/ansible/blockexample.txt
> 
> marker: “#BEGIN ANSIBLE MANAGED BLOCK”
> 
> block :
> 
> tree
> 
> state: absent

Outcome -

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 31, 2017, 6:06pm UTC](https://forum.ansible.com/t/blockinfile-how-to-delete-text/25386/2 "2017-08-31T18:06:29Z")

</div>

The problem is that the start marker and end marker is the same and  
blockinfile doesn't now where to start and stop.

If you take a look at the blockinfile documentation under marker you will see  
that it contain the template sign {mark} that will be changed for START or END

That way the start and end marker differ.

Just run your test without marker: and you'll see how it work since marker has  
a default value that only need to be changed if your are using more than one  
blockinfile on a file.
