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
7b2c8b30
Commit
7b2c8b30
authored
Feb 23, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2146 from dagwieers/thirsty-force
Add force= and make thirsty= an alias for backward compatibility
parents
46755670
486889bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
library/copy
+5
-4
library/get_url
+6
-5
No files found.
library/copy
View file @
7b2c8b30
...
...
@@ -48,7 +48,7 @@ options:
required: false
choices: [ "yes", "no" ]
default: "no"
thirsty
:
force
:
description:
- the default is C(yes), which will replace the remote file when contents
are different than the source. If C(no), the file will only be transferred
...
...
@@ -57,6 +57,7 @@ options:
required: false
choices: [ "yes", "no" ]
default: "yes"
aliases: [ "thirsty" ]
others:
others:
description:
...
...
@@ -78,7 +79,7 @@ def main():
src
=
dict
(
required
=
True
),
dest
=
dict
(
required
=
True
),
backup
=
dict
(
default
=
False
,
choices
=
BOOLEANS
),
thirsty
=
dict
(
default
=
'yes'
,
choices
=
BOOLEANS
),
force
=
dict
(
default
=
'yes'
,
choices
=
BOOLEANS
,
aliases
=
[
'thirsty'
]
),
),
add_file_common_args
=
True
,
)
...
...
@@ -86,7 +87,7 @@ def main():
src
=
os
.
path
.
expanduser
(
module
.
params
[
'src'
])
dest
=
os
.
path
.
expanduser
(
module
.
params
[
'dest'
])
backup
=
module
.
boolean
(
module
.
params
.
get
(
'backup'
,
False
))
thirsty
=
module
.
boolean
(
module
.
params
[
'thirsty
'
])
force
=
module
.
boolean
(
module
.
params
[
'force
'
])
if
not
os
.
path
.
exists
(
src
):
module
.
fail_json
(
msg
=
"Source
%
s failed to transfer"
%
(
src
))
...
...
@@ -97,7 +98,7 @@ def main():
md5sum_dest
=
None
if
os
.
path
.
exists
(
dest
):
if
not
thirsty
:
if
not
force
:
module
.
exit_json
(
msg
=
"file already exists"
,
src
=
src
,
dest
=
dest
,
changed
=
False
)
if
(
os
.
path
.
isdir
(
dest
)):
basename
=
os
.
path
.
basename
(
src
)
...
...
library/get_url
View file @
7b2c8b30
...
...
@@ -42,10 +42,10 @@ options:
dest:
description:
- absolute path of where to download the file to.
- If I(dest) is a directory, the basename of the file on the remote server will be used. If a directory, C(
thirsty
=yes) must also be set.
- If I(dest) is a directory, the basename of the file on the remote server will be used. If a directory, C(
force
=yes) must also be set.
required: true
default: null
thirsty
:
force
:
description:
- if C(yes), will download the file every time and replace the
file if the contents change. If C(no), the file will only be downloaded if
...
...
@@ -55,6 +55,7 @@ options:
required: false
choices: [ "yes", "no" ]
default: "no"
aliases: [ "thirsty" ]
others:
description:
- all arguments accepted by the M(file) module also work here
...
...
@@ -194,19 +195,19 @@ def main():
argument_spec
=
dict
(
url
=
dict
(
required
=
True
),
dest
=
dict
(
required
=
True
),
thirsty
=
dict
(
default
=
'no'
,
choices
=
BOOLEANS
)
force
=
dict
(
default
=
'no'
,
choices
=
BOOLEANS
,
aliases
=
[
'thirsty'
]
)
),
add_file_common_args
=
True
)
url
=
module
.
params
[
'url'
]
dest
=
os
.
path
.
expanduser
(
module
.
params
[
'dest'
])
thirsty
=
module
.
boolean
(
module
.
params
[
'thirsty
'
])
force
=
module
.
boolean
(
module
.
params
[
'force
'
])
if
os
.
path
.
isdir
(
dest
):
dest
=
os
.
path
.
join
(
dest
,
url_filename
(
url
))
if
not
thirsty
:
if
not
force
:
if
os
.
path
.
exists
(
dest
):
module
.
exit_json
(
msg
=
"file already exists"
,
dest
=
dest
,
url
=
url
,
changed
=
False
)
...
...
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