|
|
@ -77,16 +77,11 @@ options:
|
|
|
|
get the original file back if you somehow clobbered it incorrectly.
|
|
|
|
get the original file back if you somehow clobbered it incorrectly.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: 'no'
|
|
|
|
follow:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- 'This flag indicates that filesystem links, if they exist, should be followed.'
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
|
|
|
|
default: 'no'
|
|
|
|
|
|
|
|
version_added: "2.1"
|
|
|
|
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- This module supports check mode.
|
|
|
|
- This module supports check mode.
|
|
|
|
- When using 'with_*' loops be aware that if you do not set a unique mark the block will be overwritten on each iteration.
|
|
|
|
- When using 'with_*' loops be aware that if you do not set a unique mark the block will be overwritten on each iteration.
|
|
|
|
- As of Ansible 2.3, the I(dest) option has been changed to I(path) as default, but I(dest) still works as well.
|
|
|
|
- As of Ansible 2.3, the I(dest) option has been changed to I(path) as default, but I(dest) still works as well.
|
|
|
|
|
|
|
|
- Option I(follow) has been removed in version 2.5, because this module modifies the contents of the file so I(follow=no) doesn't make sense.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = r"""
|
|
|
|
EXAMPLES = r"""
|
|
|
@ -203,8 +198,6 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
params = module.params
|
|
|
|
params = module.params
|
|
|
|
path = params['path']
|
|
|
|
path = params['path']
|
|
|
|
if module.boolean(params.get('follow', None)):
|
|
|
|
|
|
|
|
path = os.path.realpath(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.isdir(path):
|
|
|
|
if os.path.isdir(path):
|
|
|
|
module.fail_json(rc=256,
|
|
|
|
module.fail_json(rc=256,
|
|
|
@ -315,7 +308,9 @@ def main():
|
|
|
|
if changed and not module.check_mode:
|
|
|
|
if changed and not module.check_mode:
|
|
|
|
if module.boolean(params['backup']) and path_exists:
|
|
|
|
if module.boolean(params['backup']) and path_exists:
|
|
|
|
module.backup_local(path)
|
|
|
|
module.backup_local(path)
|
|
|
|
write_changes(module, result, path)
|
|
|
|
# We should always follow symlinks so that we change the real file
|
|
|
|
|
|
|
|
real_path = os.path.realpath(params['path'])
|
|
|
|
|
|
|
|
write_changes(module, result, real_path)
|
|
|
|
|
|
|
|
|
|
|
|
if module.check_mode and not path_exists:
|
|
|
|
if module.check_mode and not path_exists:
|
|
|
|
module.exit_json(changed=changed, msg=msg, diff=diff)
|
|
|
|
module.exit_json(changed=changed, msg=msg, diff=diff)
|
|
|
|