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
b753625d
Commit
b753625d
authored
May 02, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refuse to convert a non-empty directory into a link with the file module
Also adds an integration test for the above. Fixes #7254
parent
deb532c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
library/files/file
+7
-2
test/integration/roles/test_file/tasks/main.yml
+44
-1
No files found.
library/files/file
View file @
b753625d
...
@@ -192,8 +192,13 @@ def main():
...
@@ -192,8 +192,13 @@ def main():
if
state
==
'hard'
:
if
state
==
'hard'
:
if
not
os
.
path
.
isabs
(
src
):
if
not
os
.
path
.
isabs
(
src
):
module
.
fail_json
(
msg
=
"absolute paths are required"
)
module
.
fail_json
(
msg
=
"absolute paths are required"
)
elif
prev_state
==
'directory'
:
elif
prev_state
in
[
'file'
,
'hard'
,
'directory'
]
and
not
force
:
if
not
force
:
module
.
fail_json
(
path
=
path
,
msg
=
'refusing to convert between
%
s and
%
s for
%
s'
%
(
prev_state
,
state
,
src
))
elif
len
(
os
.
listdir
(
path
))
>
0
:
# refuse to replace a directory that has files in it
module
.
fail_json
(
path
=
path
,
msg
=
'the directory
%
s is not empty, refusing to convert it'
%
path
)
elif
prev_state
in
[
'file'
,
'hard'
]
and
not
force
:
module
.
fail_json
(
path
=
path
,
msg
=
'refusing to convert between
%
s and
%
s for
%
s'
%
(
prev_state
,
state
,
src
))
module
.
fail_json
(
path
=
path
,
msg
=
'refusing to convert between
%
s and
%
s for
%
s'
%
(
prev_state
,
state
,
src
))
if
prev_state
==
'absent'
:
if
prev_state
==
'absent'
:
...
...
test/integration/roles/test_file/tasks/main.yml
View file @
b753625d
...
@@ -183,5 +183,48 @@
...
@@ -183,5 +183,48 @@
that
:
that
:
-
"
file13_result.changed
==
true"
-
"
file13_result.changed
==
true"
-
name
:
remo
t
e directory foobar
-
name
:
remo
v
e directory foobar
file
:
path={{output_dir}}/foobar state=absent
file
:
path={{output_dir}}/foobar state=absent
register
:
file14_result
-
name
:
verify that the directory was removed
assert
:
that
:
-
'
file14_result.changed
==
true'
-
'
file14_result.state
==
"absent"'
-
name
:
create a test sub-directory
file
:
dest={{output_dir}}/sub1 state=directory
register
:
file15_result
-
name
:
verify that the new directory was created
assert
:
that
:
-
'
file15_result.changed
==
true'
-
'
file15_result.state
==
"directory"'
-
name
:
create test files in the sub-directory
file
:
dest={{output_dir}}/sub1/{{item}} state=touch
with_items
:
-
file1
-
file2
-
file3
register
:
file16_result
-
name
:
verify the files were created
assert
:
that
:
-
'
item.changed
==
true'
-
'
item.state
==
"file"'
with_items
:
file16_result.results
-
name
:
try to force the sub-directory to a link
file
:
src={{output_dir}}/testing dest={{output_dir}}/sub1 state=link force=yes
register
:
file17_result
ignore_errors
:
true
-
name
:
verify the directory was not replaced with a link
assert
:
that
:
-
'
file17_result.failed
==
true'
-
'
file17_result.state
==
"directory"'
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