更新时间:2023-02-17 23:05:28
我通过稍微改进 @mattyoung-redhatmatt 的答案来做到这一点.事实证明,replace
模块可以很好地处理多行正则表达式和反向引用:
I managed to do exactly this by slightly improving @mattyoung-redhatmatt's answer. As it turns out, the replace
module handles multi line regular expressions and backreferences just fine:
- name: AllowOverride all
replace:
dest=/etc/apache2/apache2.conf
regexp='(<[dD]irectory /var/www/>[^<]*)AllowOverride None'
replace='\1AllowOverride All'
backup=yes
sudo: yes
notify:
- restart apache