Merge pull request #1541 from dhozac/fix-first_available_file
Fix first_available_file and add test-case
This commit is contained in:
commit
1b8d912d2a
3 changed files with 11 additions and 8 deletions
|
@ -56,16 +56,16 @@ class ActionModule(object):
|
|||
if 'first_available_file' in inject:
|
||||
found = False
|
||||
for fn in self.runner.module_vars.get('first_available_file'):
|
||||
fn = utils.template(self.runner.basedir, fn, inject)
|
||||
fn = utils.path_dwim(self.runner.basedir, fn)
|
||||
if os.path.exists(fn):
|
||||
source = fn
|
||||
fnt = utils.template(self.runner.basedir, fn, inject)
|
||||
fnd = utils.path_dwim(self.runner.basedir, fnt)
|
||||
if os.path.exists(fnd):
|
||||
source = fnt
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
result = dict(failed=True, msg="could not find src in first_available_file list")
|
||||
return ReturnData(conn=conn, comm_ok=False, result=result)
|
||||
|
||||
else:
|
||||
source = utils.template(self.runner.basedir, source, inject)
|
||||
|
||||
# template the source data locally & transfer
|
||||
|
|
|
@ -130,7 +130,7 @@ class TestPlaybook(unittest.TestCase):
|
|||
return result
|
||||
|
||||
def test_one(self):
|
||||
pb = os.path.join(self.test_dir, 'playbook1.yml')
|
||||
pb = 'test/playbook1.yml'
|
||||
actual = self._run(pb)
|
||||
|
||||
# if different, this will output to screen
|
||||
|
|
|
@ -41,7 +41,10 @@
|
|||
# not be triggered twice because it's already triggered
|
||||
|
||||
- name: test template
|
||||
action: template src=sample.j2 dest=/tmp/ansible_test_data_template.out
|
||||
action: template src=$item dest=/tmp/ansible_test_data_template.out
|
||||
first_available_file:
|
||||
- nonexistantfile
|
||||
- sample.j2
|
||||
notify:
|
||||
- on change 1
|
||||
- on change 2
|
||||
|
|
Loading…
Reference in a new issue