The before is also regexp so you need to escape the [] too.
If you do that it will delete everything from the start of the file to
the [sssd]
> But instead it pretty much deletes the whole file.
Since it can't find [sssd] because of the missing escape it will remove
the content of every line.
> I have a workaround using
> sed via the command module. But I'd like to use replace or lineinfile.
> Any
> ideas? I also figured I could use a loop of regexps. Just seem like
> this
> should be simple. Heck the sed is simple for this.
>
> sed -i '/^\[domain\/example\]/,/^$/d' /etc/sssd/sssd.conf
This one will work more or less like you sed
- replace:
path: /home/admin/sssd.conf
regexp: '(?s)\[domain/example\].*?^$'
backup: yes
--
Kai Stian Olstad