Interface preference for adding text at start/end of a config-file line?

How many different processes will modify your file?
Would templates work for you?

What about this:

   - name: grab value of line DirctoryIndex
    shell: grep 'DirectoryIndex.*index.php' /etc/httpd/httpd.conf
    register: DIline

   - name: comment out DirectoryIndex
     lineinfile: dest=/etc/httpd/httpd.conf regex='DirectoryIndex' line="# $DIline.stdout"