implement lookup plugins for arbitrary enumeration over arbitrary things. See the mailing list for some cool examples.
This commit is contained in:
parent
95f9917df5
commit
37dedf719d
3 changed files with 12 additions and 5 deletions
4
copy
4
copy
|
@ -89,9 +89,9 @@ def main():
|
|||
module.fail_json(msg="Destination %s not writable" % (dest))
|
||||
if not os.access(dest, os.R_OK):
|
||||
module.fail_json(msg="Destination %s not readable" % (dest))
|
||||
# Allow dest to be directory without compromising md5 check
|
||||
if (os.path.isdir(dest)):
|
||||
module.fail_json(msg="Destination %s cannot be a directory" % (dest))
|
||||
basename = os.path.basename(src)
|
||||
dest = os.path.join(dest, basename)
|
||||
md5sum_dest = module.md5(dest)
|
||||
else:
|
||||
if not os.path.exists(os.path.dirname(dest)):
|
||||
|
|
12
file
12
file
|
@ -339,11 +339,18 @@ def main():
|
|||
params = module.params
|
||||
state = params['state']
|
||||
path = os.path.expanduser(params['path'])
|
||||
|
||||
# source is both the source of a symlink or an informational passing of the src for a template module
|
||||
# or copy module, even if this module never uses it, it is needed to key off some things
|
||||
|
||||
src = params.get('src', None)
|
||||
if src:
|
||||
src = os.path.expanduser(src)
|
||||
force = module.boolean(params['force'])
|
||||
|
||||
if src is not None and os.path.isdir(path):
|
||||
params['path'] = path = os.path.join(path, os.path.basename(src))
|
||||
|
||||
mode = params.get('mode', None)
|
||||
owner = params.get('owner', None)
|
||||
group = params.get('group', None)
|
||||
|
@ -370,6 +377,7 @@ def main():
|
|||
changed = False
|
||||
|
||||
prev_state = 'absent'
|
||||
|
||||
if os.path.lexists(path):
|
||||
if os.path.islink(path):
|
||||
prev_state = 'link'
|
||||
|
@ -392,7 +400,7 @@ def main():
|
|||
module_exit_json(path=path, changed=True)
|
||||
|
||||
if prev_state != 'absent' and prev_state != state and not force:
|
||||
module_fail_json(path=path, msg='refusing to convert between %s and %s' % (prev_state, state))
|
||||
module_fail_json(path=path, msg='refusing to convert between %s and %s for %s' % (prev_state, state, src))
|
||||
|
||||
if prev_state == 'absent' and state == 'absent':
|
||||
module_exit_json(path=path, changed=False)
|
||||
|
@ -400,7 +408,7 @@ def main():
|
|||
if state == 'file':
|
||||
|
||||
if prev_state != 'file':
|
||||
module_fail_json(path=path, msg='file does not exist, use copy or template module to create')
|
||||
module_fail_json(path=path, msg='file (%s) does not exist, use copy or template module to create' % path)
|
||||
|
||||
# set modes owners and context as needed
|
||||
changed = set_context_if_different(path, secontext, changed)
|
||||
|
|
1
fireball
1
fireball
|
@ -199,7 +199,6 @@ def serve(module, password, port, minutes):
|
|||
# password as a variable in ansible is never logged though, so it serves well
|
||||
|
||||
key = AesKey.Read(password)
|
||||
log("DEBUG KEY=%s" % key) # REALLY NEED TO REMOVE THIS, DEBUG/DEV ONLY!
|
||||
|
||||
while True:
|
||||
|
||||
|
|
Loading…
Reference in a new issue