ansible/ansible — pull request #2178 by leucos (2013-02-22 16:31:29+00:00)
Title: Improves lineinfile and adds file attr option (take #3)

Added path expanding for dest in lineinfile
Added common file arguments to lineinfile so the module gets owner,
group, mode and SE options.
Decorated existing example to demonstate usage of file options and added
a couple more examples
Message is not set accordingly when file attributes were changed
'absent' handling code now handles the case where the file doesn't
exists (was issuing a Traceback before)
File attribute handling code has been added to the 'absent' handling
function too.
File attributes handling has been grouped in 'def check_file' since it's
required in both places.
'absent' mode now returns a message like it's counterpart 'present',
telling if file attributes were altered and if lines have matched.

__Note:__
Kept the behaviour where, when called with `state=absent`, permissions ARE fixed if needed, and documented it. Seems more consistent and logical to me. Since files (or some of it's lines) managed by lineinfile are probably not pushed via ansible, this is is only way to set perms, ownership or linux context without using another file action.
Even if they're pushed via Ansible, I don't see much downside in doing this. May be few cons when file is maintained elsewhere with file (scenario of setting a different file mode in different playbooks, sounds like a playbook problem to me); this also introduce more perms checking perms when module is used. Not a big deal IMHO.

_No kitten were harmed in creating this pull request_