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
f4b59fe2
Commit
f4b59fe2
authored
Nov 01, 2013
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #4516 file module: check prev_state earlier and use that if state is not specified
parent
d478eaa6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
library/files/file
+25
-14
No files found.
library/files/file
View file @
f4b59fe2
...
...
@@ -142,7 +142,7 @@ def main():
module
=
AnsibleModule
(
argument_spec
=
dict
(
state
=
dict
(
choices
=
[
'file'
,
'directory'
,
'link'
,
'hard'
,
'touch'
,
'absent'
],
default
=
'file'
),
state
=
dict
(
choices
=
[
'file'
,
'directory'
,
'link'
,
'hard'
,
'touch'
,
'absent'
],
default
=
None
),
path
=
dict
(
aliases
=
[
'dest'
,
'name'
],
required
=
True
),
recurse
=
dict
(
default
=
'no'
,
type
=
'bool'
),
force
=
dict
(
required
=
False
,
default
=
False
,
type
=
'bool'
),
...
...
@@ -171,6 +171,30 @@ def main():
pass
module
.
exit_json
(
path
=
path
,
changed
=
False
,
appears_binary
=
appears_binary
)
prev_state
=
'absent'
if
os
.
path
.
lexists
(
path
):
if
os
.
path
.
islink
(
path
):
prev_state
=
'link'
elif
os
.
path
.
isdir
(
path
):
prev_state
=
'directory'
elif
os
.
stat
(
path
)
.
st_nlink
>
1
:
prev_state
=
'hard'
else
:
# could be many other things, but defaulting to file
prev_state
=
'file'
if
prev_state
is
not
None
and
state
is
None
:
if
not
params
.
get
(
'src'
,
None
):
# idempotent exit if state is not specified
module
.
exit_json
(
path
=
path
,
changed
=
False
)
else
:
# src is defined, need to process other operations
state
=
prev_state
elif
state
is
None
:
# set default state to file
state
=
'file'
# source is both the source of a symlink or an informational passing of the src for a template module
# or copy module, even if this module never uses it, it is needed to key off some things
...
...
@@ -190,19 +214,6 @@ def main():
changed
=
False
prev_state
=
'absent'
if
os
.
path
.
lexists
(
path
):
if
os
.
path
.
islink
(
path
):
prev_state
=
'link'
elif
os
.
path
.
isdir
(
path
):
prev_state
=
'directory'
elif
os
.
stat
(
path
)
.
st_nlink
>
1
:
prev_state
=
'hard'
else
:
# could be many other things, but defaulting to file
prev_state
=
'file'
recurse
=
params
[
'recurse'
]
if
recurse
and
state
==
'file'
and
prev_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