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
ac40ffa1
Commit
ac40ffa1
authored
Feb 25, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If remote_checksum fails because the dest is a directory, try a file within the dest.
Fixes #10300
parent
d5af0ba3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
15 deletions
+29
-15
lib/ansible/runner/action_plugins/template.py
+29
-15
No files found.
lib/ansible/runner/action_plugins/template.py
View file @
ac40ffa1
...
@@ -30,6 +30,25 @@ class ActionModule(object):
...
@@ -30,6 +30,25 @@ class ActionModule(object):
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
def
get_checksum
(
self
,
conn
,
tmp
,
dest
,
inject
,
try_directory
=
False
,
source
=
None
):
remote_checksum
=
self
.
runner
.
_remote_checksum
(
conn
,
tmp
,
dest
,
inject
)
if
remote_checksum
in
(
'0'
,
'2'
,
'3'
,
'4'
):
# Note: 1 means the file is not present which is fine; template
# will create it. 3 means directory was specified instead of file
if
try_directory
and
remote_checksum
==
'3'
and
source
:
base
=
os
.
path
.
basename
(
source
)
dest
=
os
.
path
.
join
(
dest
,
base
)
remote_checksum
=
self
.
get_checksum
(
conn
,
tmp
,
dest
,
inject
,
try_directory
=
False
)
if
remote_checksum
not
in
(
'0'
,
'2'
,
'3'
,
'4'
):
return
remote_checksum
result
=
dict
(
failed
=
True
,
msg
=
"failed to checksum remote file."
" Checksum error code:
%
s"
%
remote_checksum
)
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
return
remote_checksum
def
run
(
self
,
conn
,
tmp
,
module_name
,
module_args
,
inject
,
complex_args
=
None
,
**
kwargs
):
def
run
(
self
,
conn
,
tmp
,
module_name
,
module_args
,
inject
,
complex_args
=
None
,
**
kwargs
):
''' handler for template operations '''
''' handler for template operations '''
...
@@ -75,13 +94,6 @@ class ActionModule(object):
...
@@ -75,13 +94,6 @@ class ActionModule(object):
else
:
else
:
source
=
utils
.
path_dwim
(
self
.
runner
.
basedir
,
source
)
source
=
utils
.
path_dwim
(
self
.
runner
.
basedir
,
source
)
# Expand any user home dir specification
dest
=
self
.
runner
.
_remote_expand_user
(
conn
,
dest
,
tmp
)
if
dest
.
endswith
(
"/"
):
# CCTODO: Fix path for Windows hosts.
base
=
os
.
path
.
basename
(
source
)
dest
=
os
.
path
.
join
(
dest
,
base
)
# template the source data locally & get ready to transfer
# template the source data locally & get ready to transfer
try
:
try
:
resultant
=
template
.
template_from_file
(
self
.
runner
.
basedir
,
source
,
inject
,
vault_password
=
self
.
runner
.
vault_pass
)
resultant
=
template
.
template_from_file
(
self
.
runner
.
basedir
,
source
,
inject
,
vault_password
=
self
.
runner
.
vault_pass
)
...
@@ -89,15 +101,17 @@ class ActionModule(object):
...
@@ -89,15 +101,17 @@ class ActionModule(object):
result
=
dict
(
failed
=
True
,
msg
=
type
(
e
)
.
__name__
+
": "
+
str
(
e
))
result
=
dict
(
failed
=
True
,
msg
=
type
(
e
)
.
__name__
+
": "
+
str
(
e
))
return
ReturnData
(
conn
=
conn
,
comm_ok
=
False
,
result
=
result
)
return
ReturnData
(
conn
=
conn
,
comm_ok
=
False
,
result
=
result
)
local_checksum
=
utils
.
checksum_s
(
resultant
)
# Expand any user home dir specification
remote_checksum
=
self
.
runner
.
_remote_checksum
(
conn
,
tmp
,
dest
,
inject
)
dest
=
self
.
runner
.
_remote_expand_user
(
conn
,
dest
,
tmp
)
if
remote_checksum
in
(
'0'
,
'2'
,
'3'
,
'4'
):
directory_prepended
=
False
# Note: 1 means the file is not present which is fine; template
if
dest
.
endswith
(
"/"
):
# CCTODO: Fix path for Windows hosts.
# will create it
directory_prepended
=
True
result
=
dict
(
failed
=
True
,
msg
=
"failed to checksum remote file."
base
=
os
.
path
.
basename
(
source
)
" Checksum error code:
%
s"
%
remote_checksum
)
dest
=
os
.
path
.
join
(
dest
,
base
)
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
local_checksum
=
utils
.
checksum_s
(
resultant
)
remote_checksum
=
self
.
get_checksum
(
conn
,
tmp
,
dest
,
inject
,
not
directory_prepended
,
source
=
source
)
if
local_checksum
!=
remote_checksum
:
if
local_checksum
!=
remote_checksum
:
...
...
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