ansible/ansible — pull request #2223 by huberteff (2013-02-27 22:34:21+00:00)
Title: Add 'appendat' and 'prependat', which add text at the start/end of a line

Add 'appendat' and 'prependat', 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='#' prependat='^root:'
regexp='^#root:' state='present'

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

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

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