ansible/ansible — pull request #2419 by huberteff (2013-03-16 00:06:38+00:00)
Title: Add 'append_at' and 'prepend_at', which add text at the start/end of a line

Add 'append_at' and 'prepend_at', which take regular expressions similar
to 'insertbefore' and 'insertafter'. When matched, the text in 'line'
is appended/prepended to the end/start of the matching line.

This allows to modify a line without fully duplicating its contents
in an ansible playbook.

Examples:
1) Comment out the 'root' user in /etc/passwd:

lineinfile: dest='/etc/passwd' line='#' prepend_at='^root:'
regexp='^#root:' state='present'

2) For Apache, also display index.php files:

lineinfile: dest='/usr/pkg/etc/httpd/httpd.conf' line=' index.php'
append_at='DirectoryIndex' regexp='DirectoryIndex.*index.php'
state='present'

In both examples, the whole contents of the line are not included
in the playbook.