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
115dce02
Commit
115dce02
authored
Jul 18, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11604 from bcoca/faf_deprecated_fixes
fixed first_available_found for template
parents
493c2e48
5a5b7ff5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
34 deletions
+30
-34
lib/ansible/plugins/__init__.py
+1
-2
lib/ansible/plugins/action/__init__.py
+24
-0
lib/ansible/plugins/action/copy.py
+2
-14
lib/ansible/plugins/action/template.py
+2
-17
lib/ansible/utils/display.py
+1
-1
No files found.
lib/ansible/plugins/__init__.py
View file @
115dce02
...
@@ -250,8 +250,7 @@ class PluginLoader:
...
@@ -250,8 +250,7 @@ class PluginLoader:
if
alias_name
in
self
.
_plugin_path_cache
:
if
alias_name
in
self
.
_plugin_path_cache
:
if
not
os
.
path
.
islink
(
self
.
_plugin_path_cache
[
alias_name
]):
if
not
os
.
path
.
islink
(
self
.
_plugin_path_cache
[
alias_name
]):
d
=
Display
()
d
=
Display
()
d
.
warning
(
'
%
s has been deprecated, which means '
d
.
deprecated
(
'
%
s is kept for backwards compatibility '
'it is kept for backwards compatibility '
'but usage is discouraged. The module '
'but usage is discouraged. The module '
'documentation details page may explain '
'documentation details page may explain '
'more about this rationale.'
%
'more about this rationale.'
%
...
...
lib/ansible/plugins/action/__init__.py
View file @
115dce02
...
@@ -448,3 +448,27 @@ class ActionBase:
...
@@ -448,3 +448,27 @@ class ActionBase:
rc
=
0
rc
=
0
return
dict
(
rc
=
rc
,
stdout
=
out
,
stderr
=
err
)
return
dict
(
rc
=
rc
,
stdout
=
out
,
stderr
=
err
)
def
_get_first_available_file
(
self
,
faf
,
of
=
None
,
searchdir
=
'files'
):
self
.
_connection
.
_display
.
deprecated
(
"first_available_file, use with_first_found or lookup('first_found',...) instead"
)
for
fn
in
faf
:
fn_orig
=
fn
fnt
=
self
.
_templar
.
template
(
fn
)
if
self
.
_task
.
_role
is
not
None
:
lead
=
self
.
_task
.
_role
.
_role_path
else
:
lead
=
fnt
fnd
=
self
.
_loader
.
path_dwim_relative
(
lead
,
searchdir
,
fnt
)
if
not
os
.
path
.
exists
(
fnd
)
and
of
is
not
None
:
if
self
.
_task
.
_role
is
not
None
:
lead
=
self
.
_task
.
_role
.
_role_path
else
:
lead
=
of
fnd
=
self
.
_loader
.
path_dwim_relative
(
lead
,
searchdir
,
of
)
if
os
.
path
.
exists
(
fnd
):
return
fnd
return
None
lib/ansible/plugins/action/copy.py
View file @
115dce02
...
@@ -74,20 +74,8 @@ class ActionModule(ActionBase):
...
@@ -74,20 +74,8 @@ class ActionModule(ActionBase):
# if we have first_available_file in our vars
# if we have first_available_file in our vars
# 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
elif
faf
:
elif
faf
:
#FIXME: issue deprecation warning for first_available_file, use with_first_found or lookup('first_found',...) instead
source
=
self
.
_get_first_available_file
(
faf
,
task_vars
.
get
(
'_original_file'
,
None
))
found
=
False
if
source
is
None
:
for
fn
in
faf
:
fn_orig
=
fn
fnt
=
self
.
_templar
.
template
(
fn
)
fnd
=
self
.
_loader
.
path_dwim_relative
(
self
.
_task
.
_role
.
_role_path
,
'files'
,
fnt
)
of
=
task_vars
.
get
(
'_original_file'
,
None
)
if
not
os
.
path
.
exists
(
fnd
)
and
of
is
not
None
:
fnd
=
self
.
_loader
.
path_dwim_relative
(
of
,
'files'
,
of
)
if
os
.
path
.
exists
(
fnd
):
source
=
fnd
found
=
True
break
if
not
found
:
return
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"
)
else
:
else
:
if
self
.
_task
.
_role
is
not
None
:
if
self
.
_task
.
_role
is
not
None
:
...
...
lib/ansible/plugins/action/template.py
View file @
115dce02
...
@@ -64,23 +64,8 @@ class ActionModule(ActionBase):
...
@@ -64,23 +64,8 @@ class ActionModule(ActionBase):
tmp
=
self
.
_make_tmp_path
()
tmp
=
self
.
_make_tmp_path
()
if
faf
:
if
faf
:
#FIXME: issue deprecation warning for first_available_file, use with_first_found or lookup('first_found',...) instead
source
=
self
.
_get_first_available_file
(
faf
,
task_vars
.
get
(
'_original_file'
,
None
,
'templates'
))
found
=
False
if
source
is
None
:
for
fn
in
faf
:
fn_orig
=
fn
fnt
=
self
.
_templar
.
template
(
fn
)
fnd
=
self
.
_loader
.
path_dwim
(
self
.
_task
.
_role_
.
_role_path
,
'templates'
,
fnt
)
if
not
os
.
path
.
exists
(
fnd
):
of
=
task_vars
.
get
(
'_original_file'
,
None
)
if
of
is
not
None
:
fnd
=
self
.
_loader
.
path_dwim
(
self
.
_task
.
_role_
.
_role_path
,
'templates'
,
of
)
if
os
.
path
.
exists
(
fnd
):
source
=
fnd
found
=
True
break
if
not
found
:
return
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"
)
else
:
else
:
if
self
.
_task
.
_role
is
not
None
:
if
self
.
_task
.
_role
is
not
None
:
...
...
lib/ansible/utils/display.py
View file @
115dce02
...
@@ -111,7 +111,7 @@ class Display:
...
@@ -111,7 +111,7 @@ class Display:
else
:
else
:
self
.
display
(
"<
%
s>
%
s"
%
(
host
,
msg
),
color
=
'blue'
,
screen_only
=
True
)
self
.
display
(
"<
%
s>
%
s"
%
(
host
,
msg
),
color
=
'blue'
,
screen_only
=
True
)
def
deprecated
(
self
,
msg
,
version
,
removed
=
False
):
def
deprecated
(
self
,
msg
,
version
=
None
,
removed
=
False
):
''' used to print out a deprecation message.'''
''' used to print out a deprecation message.'''
if
not
removed
and
not
C
.
DEPRECATION_WARNINGS
:
if
not
removed
and
not
C
.
DEPRECATION_WARNINGS
:
...
...
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