blockinfile state:absent is not working, I'm trying to remove mulitple lines but not working

please someone help me to get answer for my query!

please someone help me to get answer for my query!

---
- hosts: testuser
  become: yes
  tasks:
  - name: removelines
    blockinfile:
      block: |

              ################ request ###################
              User_Alias S3_OPS=pams3fedqaadmin
              S3_OPS ALL=(ALL) ALL
              ####################################################"
      path: /tmp/test
      state: absent
      backup: yes

You'll need to move your markers from block to marker_begin and marker_end

V/r,
James Cassell

>
> please someone help me to get answer for my query!
>
> ---
> - hosts: testuser
> become: yes
> tasks:
> - name: removelines
> blockinfile:
> block: |
>
> ################ request ###################
> User_Alias S3_OPS=pams3fedqaadmin
> S3_OPS ALL=(ALL) ALL
> ####################################################"
> path: /tmp/test
> state: absent
> backup: yes
>

You'll need to move your markers from block to marker_begin and marker_end

You'll also need to set marker.

Hi James,

Still same problem! Can you please see below entries and correct me if anything wrong in that?

Hi James,

Still same problem! Can you please see below entries and correct me if
anything wrong in that?

---
- hosts: xerox
  become: yes
  tasks:
  - name: removelines
    blockinfile:
      marker_begin: "################ REQ000000931296 ###################"
      content: |
              User_Alias S3_OPS=pams3fedqaadmin
              S3_OPS ALL=(ALL) ALL
      marker_end: "####################################################"

Also set marker: "{mark}"

Hi James,

Thank you so much for your help, its working perfect.