1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Some tweaks to first_available_file mostly in terms of error handling and not trying src= to be present

as it is not used here.
This commit is contained in:
Michael DeHaan 2012-04-26 23:00:33 -04:00
parent b56efa7809
commit 3804910187

View file

@ -385,7 +385,7 @@ class Runner(object):
options = utils.parse_kv(self.module_args) options = utils.parse_kv(self.module_args)
source = options.get('src', None) source = options.get('src', None)
dest = options.get('dest', None) dest = options.get('dest', None)
if source is None or dest is None: if (source is None and not 'first_available_file' in self.module_vars) or dest is None:
return (host, True, dict(failed=True, msg="src and dest are required"), '') return (host, True, dict(failed=True, msg="src and dest are required"), '')
# apply templating to source argument # apply templating to source argument
@ -402,7 +402,7 @@ class Runner(object):
found = True found = True
break break
if not found: if not found:
return (host, True, dict(failed=True, msg="could not find src"), '') return (host, True, dict(failed=True, msg="could not find src in first_available_file list"), '')
source = utils.template(source, inject, self.setup_cache) source = utils.template(source, inject, self.setup_cache)
@ -489,7 +489,7 @@ class Runner(object):
source = options.get('src', None) source = options.get('src', None)
dest = options.get('dest', None) dest = options.get('dest', None)
metadata = options.get('metadata', None) metadata = options.get('metadata', None)
if source is None or dest is None: if (source is None and 'first_available_file' not in self.module_vars) or dest is None:
return (host, True, dict(failed=True, msg="src and dest are required"), '') return (host, True, dict(failed=True, msg="src and dest are required"), '')
# apply templating to source argument so vars can be used in the path # apply templating to source argument so vars can be used in the path
@ -506,7 +506,7 @@ class Runner(object):
found = True found = True
break break
if not found: if not found:
return (host, True, dict(failed=True, msg="could not find src"), '') return (host, True, dict(failed=True, msg="could not find src in first_available_file list"), '')
source = utils.template(source, inject, self.setup_cache) source = utils.template(source, inject, self.setup_cache)
@ -555,6 +555,7 @@ class Runner(object):
# modify file attribs if needed # modify file attribs if needed
if ok: if ok:
executed = executed.replace("copy","template",1)
return self._chain_file_module(conn, tmp, data, err, options, executed) return self._chain_file_module(conn, tmp, data, err, options, executed)
else: else:
return (host, ok, data, err) return (host, ok, data, err)