Reputation: 29
I have a file, It has a line
DocumentRoot path/to/folder
I have to remove this line, What should be the regular expression. ?
Upvotes: 1
Views: 13561
Reputation: 5648
You can do with http://docs.ansible.com/ansible/lineinfile_module.html:
- lineinfile:
dest: /etc/apache2/sites-enabled/000-default
state: absent
regexp: "^DocumentRoot"
or http://docs.ansible.com/ansible/replace_module.html:
- replace:
dest: /etc/apache2/sites-enabled/000-default
regexp: "^DocumentRoot"
regexp: '^(DocumentRoot)\s+[^\n]*\n$'
replace: '#\1'
validate: '/usr/sbin/apache2ctl -f %s -t'
PS:
But I didn't check if regexp's were right =) Also you can use template module: http://docs.ansible.com/ansible/template_module.html or template and assemble module: http://docs.ansible.com/ansible/assemble_module.html
Upvotes: 6
Reputation: 3253
http://docs.ansible.com/ansible/lineinfile_module.html
Regex: "^DocumentRoot path/to/folder$"
Upvotes: 3