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

Quick fix for first_available_file and roles

This commit is contained in:
Darryl Stoflet 2013-04-11 20:40:23 -07:00
parent a05361f515
commit c63207bf75
2 changed files with 5 additions and 4 deletions

View file

@ -55,10 +55,11 @@ class ActionModule(object):
if 'first_available_file' in inject: if 'first_available_file' in inject:
found = False found = False
for fn in inject.get('first_available_file'): for fn in inject.get('first_available_file'):
fn_orig = fn
fn = template.template(self.runner.basedir, fn, inject) fn = template.template(self.runner.basedir, fn, inject)
fn = utils.path_dwim(self.runner.basedir, fn) fn = utils.path_dwim(self.runner.basedir, fn)
if not os.path.exists(fn) and '_original_file' in inject: if not os.path.exists(fn) and '_original_file' in inject:
fn = utils.path_dwim_relative(inject['_original_file'], 'files', fn, self.runner.basedir, check=False) fn = utils.path_dwim_relative(inject['_original_file'], 'files', fn_orig, self.runner.basedir, check=False)
if os.path.exists(fn): if os.path.exists(fn):
source = fn source = fn
found = True found = True

View file

@ -54,15 +54,15 @@ class ActionModule(object):
# look up the files and use the first one we find as src # look up the files and use the first one we find as src
if 'first_available_file' in inject: if 'first_available_file' in inject:
found = False found = False
for fn in self.runner.module_vars.get('first_available_file'): for fn in self.runner.module_vars.get('first_available_file'):
fn_orig = fn
fnt = template.template(self.runner.basedir, fn, inject) fnt = template.template(self.runner.basedir, fn, inject)
fnd = utils.path_dwim(self.runner.basedir, fnt) fnd = utils.path_dwim(self.runner.basedir, fnt)
if not os.path.exists(fnd) and '_original_file' in inject: if not os.path.exists(fnd) and '_original_file' in inject:
fnd = utils.path_dwim_relative(inject['_original_file'], 'templates', fnd, self.runner.basedir, check=False) fnd = utils.path_dwim_relative(inject['_original_file'], 'templates', fn_orig, self.runner.basedir, check=False)
if os.path.exists(fnd): if os.path.exists(fnd):
source = fnt source = fnd
found = True found = True
break break
if not found: if not found: