I tried to modify a specific line which is between "<Directory /var/www/>" and ""and after "Options Indexes FollowSymLinks". The line is : "AllowOverride None" and i am interested in changing it to "AllowOverride All". I used marker_begin and marker_end to delete lines between them and then insert the new one again but it did not work. I used regex to find the block in file. Also I used match for "Options Indexes FollowSymLinks" and tried to delete the line "AllowOverride None" and use again match and insertafter the line "AllowOverride All", but I could not do anything. here is what I did with blockinfile:
- name: delete override line
blockinfile:
path: /etc/apache2/apache2.conf
marker_begin: "<Directory /var/www/>"
marker_end: "</Directory>"
block: ""
and this is what I expected to see:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
It seems, Ansible does not search lines which start with the sign "<".