|
|
@ -196,6 +196,8 @@ def main():
|
|
|
|
if prev_state != 'absent' and state == 'absent':
|
|
|
|
if prev_state != 'absent' and state == 'absent':
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if prev_state == 'directory':
|
|
|
|
if prev_state == 'directory':
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
if os.path.islink(path):
|
|
|
|
if os.path.islink(path):
|
|
|
|
os.unlink(path)
|
|
|
|
os.unlink(path)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -204,6 +206,8 @@ def main():
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
module.exit_json(msg="rmtree failed")
|
|
|
|
module.exit_json(msg="rmtree failed")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
os.unlink(path)
|
|
|
|
os.unlink(path)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception, e:
|
|
|
|
module.fail_json(path=path, msg=str(e))
|
|
|
|
module.fail_json(path=path, msg=str(e))
|
|
|
@ -225,6 +229,8 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
elif state == 'directory':
|
|
|
|
elif state == 'directory':
|
|
|
|
if prev_state == 'absent':
|
|
|
|
if prev_state == 'absent':
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
os.makedirs(path)
|
|
|
|
os.makedirs(path)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
|
@ -254,6 +260,8 @@ def main():
|
|
|
|
module.fail_json(path=path, src=src, msg='src file does not exist')
|
|
|
|
module.fail_json(path=path, src=src, msg='src file does not exist')
|
|
|
|
|
|
|
|
|
|
|
|
if prev_state == 'absent':
|
|
|
|
if prev_state == 'absent':
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
os.symlink(src, path)
|
|
|
|
os.symlink(src, path)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
elif prev_state == 'link':
|
|
|
|
elif prev_state == 'link':
|
|
|
@ -261,6 +269,8 @@ def main():
|
|
|
|
if not os.path.isabs(old_src):
|
|
|
|
if not os.path.isabs(old_src):
|
|
|
|
old_src = os.path.join(os.path.dirname(path), old_src)
|
|
|
|
old_src = os.path.join(os.path.dirname(path), old_src)
|
|
|
|
if old_src != src:
|
|
|
|
if old_src != src:
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
os.unlink(path)
|
|
|
|
os.unlink(path)
|
|
|
|
os.symlink(src, path)
|
|
|
|
os.symlink(src, path)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
@ -270,10 +280,10 @@ def main():
|
|
|
|
# set modes owners and context as needed
|
|
|
|
# set modes owners and context as needed
|
|
|
|
|
|
|
|
|
|
|
|
file_args = module.load_file_common_arguments(module.params)
|
|
|
|
file_args = module.load_file_common_arguments(module.params)
|
|
|
|
changed = module.set_context_if_different(path, file_args['secontext'], changed)
|
|
|
|
changed = module.set_context_if_different(path, file_args['secontext'], changed)
|
|
|
|
changed = module.set_owner_if_different(path, file_args['owner'], changed)
|
|
|
|
changed = module.set_owner_if_different(path, file_args['owner'], changed)
|
|
|
|
changed = module.set_group_if_different(path, file_args['group'], changed)
|
|
|
|
changed = module.set_group_if_different(path, file_args['group'], changed)
|
|
|
|
changed = module.set_mode_if_different(path, file_args['mode'], changed)
|
|
|
|
changed = module.set_mode_if_different(path, file_args['mode'], changed)
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(dest=path, src=src, changed=changed)
|
|
|
|
module.exit_json(dest=path, src=src, changed=changed)
|
|
|
|
|
|
|
|
|
|
|
|