Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
e7abe064
Commit
e7abe064
authored
Jun 13, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added first_found to template
parent
8ee4c726
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
26 deletions
+22
-26
lib/ansible/plugins/action/template.py
+22
-26
No files found.
lib/ansible/plugins/action/template.py
View file @
e7abe064
...
@@ -51,42 +51,38 @@ class ActionModule(ActionBase):
...
@@ -51,42 +51,38 @@ class ActionModule(ActionBase):
source
=
self
.
_task
.
args
.
get
(
'src'
,
None
)
source
=
self
.
_task
.
args
.
get
(
'src'
,
None
)
dest
=
self
.
_task
.
args
.
get
(
'dest'
,
None
)
dest
=
self
.
_task
.
args
.
get
(
'dest'
,
None
)
faf
=
task_vars
.
get
(
'first_available_file'
,
None
)
if
(
source
is
None
and
'first_available_file'
not
in
task_vars
)
or
dest
is
None
:
if
(
source
is
None
and
faf
is
not
None
)
or
dest
is
None
:
return
dict
(
failed
=
True
,
msg
=
"src and dest are required"
)
return
dict
(
failed
=
True
,
msg
=
"src and dest are required"
)
if
tmp
is
None
:
if
tmp
is
None
:
tmp
=
self
.
_make_tmp_path
()
tmp
=
self
.
_make_tmp_path
()
##################################################################################################
if
faf
:
# FIXME: this all needs to be sorted out
#FIXME: issue deprecation warning for first_available_file, use with_first_found or lookup('first_found',...) instead
##################################################################################################
found
=
False
# if we have first_available_file in our vars
for
fn
in
faf
:
# look up the files and use the first one we find as src
fn_orig
=
fn
#if 'first_available_file' in task_vars:
fnt
=
self
.
_templar
.
template
(
fn
)
# found = False
fnd
=
self
.
_loader
.
path_dwim
(
self
.
_task
.
_role_
.
_role_path
,
'templates'
,
fnt
)
# for fn in task_vars.get('first_available_file'):
# fn_orig = fn
if
not
os
.
path
.
exists
(
fnd
):
# fnt = template.template(self.runner.basedir, fn, task_vars)
of
=
task_vars
.
get
(
'_original_file'
,
None
)
# fnd = utils.path_dwim(self.runner.basedir, fnt)
if
of
is
not
None
:
# if not os.path.exists(fnd) and '_original_file' in task_vars:
fnd
=
self
.
_loader
.
path_dwim
(
self
.
_task
.
_role_
.
_role_path
,
'templates'
,
of
)
# fnd = utils.path_dwim_relative(task_vars['_original_file'], 'templates', fnt, self.runner.basedir, check=False)
# if os.path.exists(fnd):
if
os
.
path
.
exists
(
fnd
):
# source = fnd
source
=
fnd
# found = True
found
=
True
# break
break
# if not found:
if
not
found
:
# result = dict(failed=True, msg="could not find src in first_available_file list")
return
dict
(
failed
=
True
,
msg
=
"could not find src in first_available_file list"
)
# return ReturnData(conn=conn, comm_ok=False, result=result)
else
:
#else:
if
1
:
if
self
.
_task
.
_role
is
not
None
:
if
self
.
_task
.
_role
is
not
None
:
source
=
self
.
_loader
.
path_dwim_relative
(
self
.
_task
.
_role
.
_role_path
,
'templates'
,
source
)
source
=
self
.
_loader
.
path_dwim_relative
(
self
.
_task
.
_role
.
_role_path
,
'templates'
,
source
)
else
:
else
:
source
=
self
.
_loader
.
path_dwim
(
source
)
source
=
self
.
_loader
.
path_dwim
(
source
)
##################################################################################################
# END FIXME
##################################################################################################
# Expand any user home dir specification
# Expand any user home dir specification
dest
=
self
.
_remote_expand_user
(
dest
,
tmp
)
dest
=
self
.
_remote_expand_user
(
dest
,
tmp
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment