On torsdag 31. august 2017 18.24.14 CEST Anfield wrote:
> 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
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.
--
Kai Stian Olstad